diff --git a/install_yamls_setup/README.md b/install_yamls_setup/README.md index dd59dd52..b399498f 100644 --- a/install_yamls_setup/README.md +++ b/install_yamls_setup/README.md @@ -8,13 +8,15 @@ See `install_yamls_setup/roles/podified_cp/defaults/main.yaml` for variables and their default values. In addition to that these variables need to be defined: - openshift_pull_secret: + openshift_pull_secret: '' podman_dockerio_user: podman_dockerio_password: podman_quayio_user: podman_quayio_password: -The recommended way to manage those secrets is using `ansible-vault`. +The recommended way to manage those secrets is using `ansible-vault`. Pay attention that +`openshift_pull_secret` needs to be a string and hence the JSON data needs to be put in +quotes. ## Playbook diff --git a/install_yamls_setup/roles/podified_cp/defaults/main.yaml b/install_yamls_setup/roles/podified_cp/defaults/main.yaml index c0c238c8..5ee2e255 100644 --- a/install_yamls_setup/roles/podified_cp/defaults/main.yaml +++ b/install_yamls_setup/roles/podified_cp/defaults/main.yaml @@ -8,15 +8,11 @@ operators_git_repos: dest: ~/octavia-operator version: main # Optional repositories: - - repo: https://github.com/openstack-k8s-operators/keystone-operator.git - dest: ~/keystone-operator - depth: 10 - - repo: https://github.com/openstack-k8s-operators/placement-operator.git - dest: ~/placement-operator - depth: 10 - repo: https://github.com/openstack-k8s-operators/neutron-operator.git dest: ~/neutron-operator + depth: 10 - repo: https://github.com/openstack-k8s-operators/lib-common.git dest: ~/lib-common -make_crc_cpus: 10 -make_crc_memory: 18000 +make_crc_cpus: 20 +make_crc_memory: 40000 +make_crc_disk: 70 diff --git a/install_yamls_setup/roles/podified_cp/files/launch.json b/install_yamls_setup/roles/podified_cp/files/launch.json index 962f066b..2d679364 100644 --- a/install_yamls_setup/roles/podified_cp/files/launch.json +++ b/install_yamls_setup/roles/podified_cp/files/launch.json @@ -2,15 +2,17 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch Octavia Operator", + "name": "Launch Package", "type": "go", "request": "launch", "mode": "auto", - "program": "${workspaceFolder}/octavia-operator/main.go", - "cwd": "${fileDirname}", + "program": "${fileWorkspaceFolder}/main.go", + "cwd": "${fileWorkspaceFolder}", "preLaunchTask": "Run make", "env": { - "OPERATOR_TEMPLATES": "${workspaceFolder}/octavia-operator/templates" + "WATCH_NAMESPACE": "openstack", + "OPERATOR_TEMPLATES": "./templates", + "ENABLE_WEBHOOKS": "false" } } ] diff --git a/install_yamls_setup/roles/podified_cp/files/octavia_v1beta1_octavia.yaml b/install_yamls_setup/roles/podified_cp/files/octavia_v1beta1_octavia.yaml new file mode 100644 index 00000000..efd95649 --- /dev/null +++ b/install_yamls_setup/roles/podified_cp/files/octavia_v1beta1_octavia.yaml @@ -0,0 +1,70 @@ +apiVersion: octavia.openstack.org/v1beta1 +kind: Octavia +metadata: + name: octavia +spec: + databaseInstance: openstack + databaseUser: octavia + serviceUser: octavia + rabbitMqClusterName: rabbitmq + secret: osp-secret + debug: + dbSync: false + service: false + preserveJobs: false + customServiceConfig: | + [DEFAULT] + debug = true + octaviaHousekeeping: + databaseInstance: openstack + databaseUser: octavia + serviceUser: octavia + serviceAccount: octavia + role: housekeeping + certssecret: todo + secret: osp-secret + preserveJobs: false + containerImage: quay.io/podified-antelope-centos9/openstack-octavia-housekeeping:current-podified + customServiceConfig: | + [DEFAULT] + debug = true + octaviaHealthManager: + databaseInstance: openstack + databaseUser: octavia + serviceUser: octavia + serviceAccount: octavia + role: healthmanager + certssecret: todo + secret: osp-secret + preserveJobs: false + containerImage: quay.io/podified-antelope-centos9/openstack-octavia-health-manager:current-podified + customServiceConfig: | + [DEFAULT] + debug = true + octaviaWorker: + databaseInstance: openstack + databaseUser: octavia + serviceUser: octavia + serviceAccount: octavia + role: worker + certssecret: todo + secret: osp-secret + preserveJobs: false + containerImage: quay.io/podified-antelope-centos9/openstack-octavia-worker:current-podified + customServiceConfig: | + [DEFAULT] + debug = true + octaviaAPI: + databaseInstance: openstack + databaseUser: octavia + serviceUser: octavia + serviceAccount: octavia + secret: osp-secret + debug: + dbSync: false + service: false + preserveJobs: false + containerImage: quay.io/podified-antelope-centos9/openstack-octavia-api:current-podified + customServiceConfig: | + [DEFAULT] + debug = true diff --git a/install_yamls_setup/roles/podified_cp/files/stack.code-workspace b/install_yamls_setup/roles/podified_cp/files/stack.code-workspace new file mode 100644 index 00000000..6400a98a --- /dev/null +++ b/install_yamls_setup/roles/podified_cp/files/stack.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "octavia-operator" + } + ], + "settings": {} +} diff --git a/install_yamls_setup/roles/podified_cp/files/tasks.json b/install_yamls_setup/roles/podified_cp/files/tasks.json index bc13c36f..60ef3d68 100644 --- a/install_yamls_setup/roles/podified_cp/files/tasks.json +++ b/install_yamls_setup/roles/podified_cp/files/tasks.json @@ -5,16 +5,13 @@ "label": "Run make", "type": "shell", "command": "make install manifests generate fmt vet", - "group": { - "kind": "build", - "isDefault": true - }, + "group": "build", "presentation": { "reveal": "always", "panel": "new" }, "options": { - "cwd": "${workspaceFolder}/octavia-operator", + "cwd": "${fileWorkspaceFolder}/", "env": { "OPERATOR_TEMPLATES": "./templates", "PATH": "~/.crc/bin/oc:${env:PATH}" @@ -23,4 +20,4 @@ "problemMatcher": [] } ] - } +} diff --git a/install_yamls_setup/roles/podified_cp/tasks/main.yaml b/install_yamls_setup/roles/podified_cp/tasks/main.yaml index 092e0700..21ff9146 100644 --- a/install_yamls_setup/roles/podified_cp/tasks/main.yaml +++ b/install_yamls_setup/roles/podified_cp/tasks/main.yaml @@ -1,4 +1,9 @@ --- +# Initial manual preparation (not needed with a c9s cloud image on PSI): +# - Create user, add to group wheel: useradd -m -G wheel stack +# - Set password for new user: passwd stack +# - Let users of wheel group use sudo without password: visudo +# - Copy local ssh key to remote machine: ssh-copy-id stack@ - name: Upgrade all packages ansible.builtin.dnf: name: "*" @@ -11,7 +16,7 @@ - name: Install required packages ansible.builtin.package: name: - - ansible + - ansible-core - gcc - git-core - make @@ -26,6 +31,7 @@ ansible.builtin.package: name: - bash-completion + - delve - tmux - vim state: latest @@ -45,19 +51,39 @@ with_items: "{{ operators_git_repos }}" tags: git -- name: Create ~/install_yamls/devsetup/pull-secret.txt +- name: Create ~/pull-secret.txt template: src: pull-secret.txt.j2 - dest: "~/install_yamls/devsetup/pull-secret.txt" - tags: [crc, pull-secret] + dest: "~/pull-secret.txt" + tags: [crc, pre-config] + +- name: Ensure ~/.config/openstack directory exists + ansible.builtin.file: + path: ~/.config/openstack + state: directory + mode: '0755' + tags: [crc, pre-config] + +- name: Set up ~/.config/openstack/clouds.yaml + copy: + src: clouds.yaml + dest: ~/.config/openstack/clouds.yaml + tags: [crc, pre-config] - name: Create devsetup using make (may take 30 minutes or more) - shell: - cmd: "{{ item }}" + make: + target: crc + params: + CPUS: "{{ make_crc_cpus }}" + MEMORY: "{{ make_crc_memory }}" + DISK: "{{ make_crc_disk }}" + chdir: "~/install_yamls/devsetup" + tags: crc + +- name: Run make download_tools + make: + target: download_tools chdir: "~/install_yamls/devsetup" - with_items: - - "CPUS={{ make_crc_cpus }} MEMORY={{ make_crc_memory }} make crc" - - make download_tools tags: crc - name: Create symbolic link for kubectl @@ -75,24 +101,40 @@ oc login -u kubeadmin -p 12345678 https://api.crc.testing:6443 make crc_storage make input - make openstack - for i in mariadb keystone ovn neutron rabbitmq ; do \ - make $i - sleep 60 - make ${i}_deploy + chdir: "~/install_yamls" + tags: crc + +- name: Run make crc_attach_default_interface + shell: + cmd: | + set +ex + eval $(crc oc-env) + oc login -u kubeadmin -p 12345678 https://api.crc.testing:6443 + make crc_attach_default_interface + exit 0 + chdir: "~/install_yamls/devsetup" + tags: crc + +- name: Deploy openstack operators + shell: + cmd: | + set +ex + eval $(crc oc-env) + oc login -u kubeadmin -p 12345678 https://api.crc.testing:6443 + oc project openstack-operators + for i in mariadb keystone ovn neutron rabbitmq ; do + make $i || break ; sleep 60 ; make ${i}_deploy || break done + make infra + make memcached_deploy + sleep 300 oc completion bash | sudo tee /etc/bash_completion.d/oc_completion openstack complete | sudo tee /etc/bash_completion.d/osc.bash_completion exit 0 - creates: "/etc/bash_completion.d/oc_completion" + #creates: "/etc/bash_completion.d/oc_completion" chdir: "~/install_yamls" tags: crc -- name: Set up ~/.config/openstack/clouds.yaml - copy: - src: clouds.yaml - dest: ~/.config/openstack/clouds.yaml - - name: Export OS_CLOUD and OS_PASSWORD in .bashrc lineinfile: path: ~/.bashrc @@ -101,6 +143,15 @@ - export PATH=$PATH:~/.crc/bin/oc - export OS_CLOUD=default - export OS_PASSWORD=12345678 + tags: config + +- name: Copy ~/.tmux.conf + copy: + src: ~/.tmux.conf + dest: ~/.tmux.conf + force: no + ignore_errors: true + tags: config - name: Copy ~/.vscode jsons copy: @@ -110,6 +161,14 @@ with_items: - launch.json - tasks.json + tags: config + +- name: Copy VSCode workspace config + copy: + src: stack.code-workspace + dest: ~/ + force: no + tags: config - name: Increase max_user_watches for VSCode become: yes @@ -117,51 +176,36 @@ path: /etc/sysctl.conf line: fs.inotify.max_user_watches=524288 notify: "Apply sysctl" + tags: config -- name: Export OS_CLOUD and OS_PASSWORD in .bashrc +- name: Add exports to .bashrc lineinfile: path: ~/.bashrc line: "{{ item }}" with_items: - export OS_CLOUD=default - export OS_PASSWORD=12345678 + - export EDPM_COMPUTE_CEPH_ENABLED=false + - export BMO_SETUP=false - export PATH=$PATH:~/.crc/bin/oc + tags: config -- name: Deploy CRD, build and push Octavia Operator image - shell: - cmd: | - set +ex - eval $(crc oc-env) - make generate - make manifests - go mod tidy - oc apply -f ~/octavia-operator/config/crd/bases/octavia.openstack.org_octaviaapis.yaml - podman rmi -f $(podman images --filter="reference=*octavia*" -q) - podman login -u {{ podman_dockerio_user }} -p \ - {{ podman_dockerio_password }} docker.io - podman login -u {{ podman_quayio_user }} -p \ - {{ podman_quayio_password }} quay.io - podman pull docker.io/library/golang:1.19 - IMAGE_TAG_BASE=quay.io/tweining/octavia-operator VERSION=0.0.1 \ - IMG=$IMAGE_TAG_BASE:v$VERSION make \ - manifests build docker-build docker-push bundle bundle-build \ - bundle-push catalog-build catalog-push - chdir: "~/octavia-operator" - tags: image - -- name: Prepare for running Octavia Operator locally - shell: - cmd: | - set +ex - eval $(crc oc-env) - oc login -u kubeadmin -p 12345678 https://api.crc.testing:6443 - OCTAVIA_IMG="quay.io/tweining/octavia-operator-index:v0.0.1" make octavia - sleep 10 - OCTAVIAAPI_IMG="quay.io/tweining/octavia-operator:v0.0.1" make octavia_deploy - sleep 50 - make octavia_cleanup - chdir: "~/install_yamls" - tags: octavia-prep +- name: Copy PodSet CR with containerImage fields set + copy: + src: octavia_v1beta1_octavia.yaml + dest: ~/octavia_v1beta1_octavia.yaml + force: no + tags: config # Now run the operator as a Go program locally (outside the Kubernetes cluster): -# cd ~/octavia-operator; OPERATOR_TEMPLATES=./templates make install run +# +# Either using VSCode or directly in a shell: +# In VSCode open the home folder and add the ~/octavia_operator folder to the +# workspace (File->Add folder to workspace...). Then open +# ~/octavia_operator/main.go and press F5 to start the debugger +# In shell: +# cd ~/octavia-operator; ENABLE_WEBHOOKS=false GOWORK= OPERATOR_TEMPLATES=./templates make install run +# +# Deploy your PodSet Custom Resource to the live OpenShift Cluster: +# oc create -f ~/octavia_v1beta1_octavia.yaml +# watch octavia pods get created using `oc get pods -w`