Knative
This role helps in installing and configuring Knative Serving and Eventing on to the Kubernetes cluster.
Requirements¶
Access to Kubernetes cluster,
For demo purpose you can have minikube cluster created locally as shown in the following example playbook,
e.g.
- name: "Create minikube Clusters"
hosts: all
vars:
# the demo work directory
work_dir: "{{ playbook_dir }}/work"
# the kubeconfig directory
kubeconfig_dir: "{{ work_dir }}/.kube"
# the kubernetes version to use with minikube
minikube_kubernetes_version: v1.21.6
# the minikube home directory
minikube_home_dir: "{{ work_dir }}/.minikube"
# minikube profiles
minikube_profiles:
mgmt: # profile name and Kubernetes context name
create: yes
destroy: no
addons:
- metallb
lbStartIP: 192.168.64.80
lbEndIP: 192.168.64.90
roles:
- role: kameshsampath.minikube
# Some extra configurations
tasks:
- name: "Configure metallb"
ansible.builtin.expect:
command: "{{ minikube_binary }} -p {{ item.key }} addons configure metallb"
responses:
"-- Enter Load Balancer Start IP:": "{{ item.value.lbStartIP}}"
"-- Enter Load Balancer End IP:": "{{ item.value.lbEndIP}}"
loop: "{{ minikube_profiles | dict2items }}"
loop_control:
label: "{{ item.key }}"
register: lb_setup_result
when: item.value.create and not item.value.destroy
- name: "Metallb result"
debug:
var: lb_setup_result
- name: "Ensure we are in mgmt context"
ansible.builtin.command:
argv:
- kubectl
- config
- use-context
- "mgmt"
environment:
KUBECONFIG: "{{ work_dir }}/.kube/config"
- name: "Ensure right permissions to kubeconfig directory"
ansible.builtin.file:
state: directory
recurse: yes
path: "{{ work_dir }}/.kube"
mode: "0700"
Variables¶
Name | Description | Default |
---|---|---|
kubernetes_spices_gitea_k8s_context | The Kubernetes context where Knative will be installed. The playbook will fail if this is not set. | |
kubernetes_spices_knative_serving_version | The Knative Serving version to use | v1.0.0 |
kubernetes_spices_knative_eventing_version | The Knative Eventing version to use | v1.0.0 |
kubernetes_spices_registries_skip_tag_resolving | The list of registry urls which need to be ignored for tag resolving | example.com,example.org,test.com,test.org,ko.local,dev.local,localhost:5000,kind-registry.local:5000 |
Example Playbook¶
- name: "Setup Knative"
hosts: localhost
vars:
kubernetes_spices_argocd_k8s_context: 'mgmt'
roles:
- { role: kameshsampath.kubernetes_spices.knative }
Important
- Based on the above example the
kubernetes_spices_knative_k8s_context
should be set tomgmt
, the context which is created by minikube.