Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCTOPUS-697: Move NFS deployment from 6_post to 4_support module #48

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions ansible/post/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@
labels: "{{ node_labels }}"
with_items: "{{ node_names.stdout_lines }}"

- name: Setup NFS storage if NFS_SERVER is provided
import_tasks: nfs_provisioner.yaml
when: nfs_server != "none"

- name: Cleanup events in openshift-etcd for cicd
when: cicd == "true"
shell: |
export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc delete events --all=true -n openshift-etcd
export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc delete events --all=true -n openshift-etcd
4 changes: 0 additions & 4 deletions ansible/support/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,3 @@
delay: 30
timeout: 600

- name: Setup NFS storage if NFS_SERVER is provided
import_tasks: nfs_provisioner.yaml
when: nfs_server != "none"

38 changes: 0 additions & 38 deletions ansible/support/tasks/nfs_provisioner.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions ansible/support/tasks/nfs_provisioner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- hosts: all

handlers:
- import_tasks: ../handlers/main.yml

tasks:

- name: Create nfs-provisioner Project
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-ns.yml') }}"

- name: Create RBAC for nfs-provisioner
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-rbac.yml') }}"

- name: Setup Authorization
shell: "export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc adm policy add-scc-to-user hostmount-anyuid system:serviceaccount:nfs-provisioner:nfs-client-provisioner"

- name: Create Deployment for nfs-provisioner
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-deployment.yml.j2') }}"

- name: Create Storage Class for nfs
kubernetes.core.k8s:
state: present
proxy: "http://{{ nfs_server }}:3128"
definition: "{{ lookup('template', '../templates/nfs-sc.yml') }}"

- name: Ensure nfs-provisioner Pod is up and running fine
shell: "export HTTPS_PROXY=http://{{ nfs_server }}:3128 && oc get pods -n nfs-provisioner"
register: pod_output
until: pod_output.stdout.find("Running") != -1
retries: 10
delay: 30

- name: Remove the block storage as the default.
shell: |
export HTTPS_PROXY=http://{{ nfs_server }}:3128 \
&& oc patch storageclass ibmc-vpc-block-10iops-tier -p '{"metadata": {"annotations": {"storageclass.kubernetes.io/is-default-class": "false"}}}'

22 changes: 22 additions & 0 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ EOF
}
}

# Dev Note: setup nfs deployment
resource "null_resource" "nfs_deployment" {
depends_on = [null_resource.config_login]
connection {
type = "ssh"
user = var.rhel_username
host = var.bastion_public_ip
private_key = file(var.private_key_file)
agent = var.ssh_agent
timeout = "${var.connection_timeout}m"
}

provisioner "remote-exec" {
inline = [<<EOF
echo 'Running ocp4-upi-compute-powervs playbook...'
cd ocp4-upi-compute-powervs/support
ANSIBLE_LOG_PATH=/root/.openshift/ocp4-upi-compute-powervs-support-nfs-deploy.log ansible-playbook -e @vars/vars.yaml tasks/nfs_provisioner.yml --become || true
EOF
]
}
}

resource "null_resource" "config_csi" {
depends_on = [null_resource.config_login, null_resource.config]
connection {
Expand Down
Loading