You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
homelab/k8s/setup_calico.yml

34 lines
1.5 KiB

- name: Setup Calico CNI Plugin
hosts: root_master
# become: yes
# become_method: sudo
# become_user: root
tasks:
- name: Check if Calico is installed
shell: "kubectl get ns | grep tigera | wc -l"
register: NS_COUNT
- name: debug
debug:
msg: "Got NS COUNT: {{ NS_COUNT.stdout|int }}"
- name: Install Calico Operator
shell: "kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/tigera-operator.yaml"
when: NS_COUNT.stdout|int < 1
- name: Create Calico setup dir
file:
path: $HOME/calico
state: directory
- name: Setup Calico Instance
shell: "{{ item }} chdir=$HOME/calico"
with_items:
- "curl https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/custom-resources.yaml | sed -e "s:192.168.0.0/16:{{ POD_NETWORK_CIDR }}:g" | kubectl apply -f -"
# - "curl https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/custom-resources.yaml -O"
# - "sed -i -e 's:192.168.0.0/16:{{ POD_NETWORK_CIDR }}:g' $HOME/calico/custom-resources.yaml"
# - "kubectl apply -f $HOME/calico/custom-resources.yaml"
args:
creates: $HOME/calico/custom-resources.yaml
- name: Check if Metrics API is installed
shell: "kubectl get pods -n kube-system | grep metrics | wc -l"
register: METRICS_COUNT
- name: Setup Metrics API
shell: "kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability.yaml"
when: METRICS_COUNT.stdout|int < 1