-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move namespace creation, dependent operators installation to playbook
The `sfconfig dev prepare` command is meant to be run multiple times, however it includes tasks that need to be performed only once, like creating namespaces and installing the cert-manager and prometheus operators. Move these tasks into a playbook in tools/microshift and include this playbook in the current `sfconfig microshift` command (it will be moved to the new unified CLI later). Change-Id: I5dd1970391dcab1837359f4c65f1ee9a84127425
- Loading branch information
Showing
3 changed files
with
76 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
- hosts: microshift | ||
tasks: | ||
- name: Create namespaces | ||
ansible.builtin.shell: kubectl get namespace {{ item }} || kubectl create namespace {{ item }} | ||
loop: | ||
- operators | ||
- sf | ||
- nodepool | ||
- name: Ensure kubectl context is correct | ||
ansible.builtin.command: kubectl config set-context microshift --namespace=sf | ||
- name: Set sf namespace labels | ||
ansible.builtin.command: kubectl label --overwrite ns sf {{ item }} | ||
loop: | ||
- "pod-security.kubernetes.io/enforce=privileged" | ||
- "pod-security.kubernetes.io/enforce-version=v1.24" | ||
- name: Set privileges on sf namespace | ||
ansible.builtin.command: oc adm policy add-scc-to-user privileged -z default | ||
- name: Set service accounts privileges | ||
ansible.builtin.command: oc adm policy add-scc-to-user privileged system:serviceaccount:{{ item.namespace }}:{{ item.serviceaccount }} | ||
loop: | ||
- namespace: operators | ||
serviceaccount: default | ||
- namespace: operators | ||
serviceaccount: prometheus-operator | ||
# TODO we do this so that this playbook doesn't rely on a local copy of the repo. There may be a better way to do that. | ||
- name: Ensure certmanager operator is installed | ||
block: | ||
- name: Apply certmanager subscription | ||
ansible.builtin.command: kubectl apply -f https://raw.githubusercontent.com/softwarefactory-project/sf-operator/master/olm-deps/cert-manager.yaml | ||
- name: Wait for pod to be ready | ||
ansible.builtin.command: > | ||
kubectl wait --for=condition=Ready --timeout 5s pods | ||
-l app.kubernetes.io/instance=cert-manager -n operators | ||
register: ready_cm | ||
until: | ||
- '"condition met" in ready_cm.stdout' | ||
- ready_cm.rc == 0 | ||
retries: 60 | ||
delay: 5 | ||
- name: Ensure prometheus operator is installed | ||
block: | ||
- name: Apply prometheus-operator subscription | ||
ansible.builtin.command: kubectl apply -f https://raw.githubusercontent.com/softwarefactory-project/sf-operator/master/olm-deps/prometheus/prometheus-subscription.yaml | ||
- name: Wait for pod to be ready | ||
ansible.builtin.command: > | ||
kubectl wait --for=condition=Ready --timeout 5s pods | ||
-l app.kubernetes.io/name=prometheus-operator -n operators | ||
register: ready_po | ||
until: | ||
- '"condition met" in ready_po.stdout' | ||
- ready_po.rc == 0 | ||
retries: 60 | ||
delay: 5 |