Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Fix kubevirt-web-ui for kubevirt-apb (#464)
Browse files Browse the repository at this point in the history
* Web ui fixes for containerized env

The playbook runs in a container already authenticated with
the cluster.  Remove root and remove copying around the config.

* Make kubevirt-web-ui namespace configurable

The default is still kubevirt-web-ui.

* Do not gather facts

Not needed and causing issues in some environments.
  • Loading branch information
mareklibra authored and Ryan Hallisey committed Nov 14, 2018
1 parent 25d9620 commit 587bbca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
5 changes: 3 additions & 2 deletions playbooks/kubevirt-web-ui/private/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Kubevirt Web UI Install Checkpoint Start
hosts: all
gather_facts: false
gather_facts: False
tasks:
- name: Set Console install 'In Progress'
run_once: true
Expand All @@ -17,6 +17,7 @@
- name: Kubevirt Web UI
# hosts: oo_first_master
hosts: masters[0]
gather_facts: False
vars:
first_master: "{{ masters[0] }}"
tasks:
Expand All @@ -26,7 +27,7 @@

- name: Kubevirt Web UI Install Checkpoint End
hosts: all
gather_facts: false
gather_facts: False
tasks:
- name: Set Console install 'Complete'
run_once: true
Expand Down
1 change: 1 addition & 0 deletions roles/kubevirt_web_ui/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
openshift_client_binary: "oc"
apb_action: "provision"
kubevirt_web_ui_namespace: "kubevirt-web-ui"

# Deviation from openshift-console: the kubevirt/web-ui is installed to an _existing_ openshift cluster,
# so "defaultNodeSelector" (see master config) takes effect causing scheduler to find no "master and compute" node.
Expand Down
2 changes: 1 addition & 1 deletion roles/kubevirt_web_ui/tasks/deprovision.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Remove kubevirt-web-ui project
shell: "{{ openshift_client_binary }} delete project kubevirt-web-ui"
shell: "{{ openshift_client_binary }} delete project {{ kubevirt_web_ui_namespace }}"

- name: Remove Kubevirt Web UI OAuth client
shell: "{{ openshift_client_binary }} delete oauthclient kubevirt-web-ui"
Expand Down
21 changes: 7 additions & 14 deletions roles/kubevirt_web_ui/tasks/provision.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
---
- name: Check if kubevirt-web-ui project exists
shell: "{{ openshift_client_binary }} projects -q | grep -w kubevirt-web-ui | awk '{ print $1 }'"
- name: Check if project for kubevirt-web-ui exists
shell: "{{ openshift_client_binary }} projects -q | grep -w {{ kubevirt_web_ui_namespace }} | awk '{ print $1 }'"
register: ns

- name: Create kubevirt-web-ui project
shell: "{{ openshift_client_binary }} new-project kubevirt-web-ui"
when: ns.stdout != "kubevirt-web-ui"
shell: "{{ openshift_client_binary }} new-project {{ kubevirt_web_ui_namespace }}"
when: ns.stdout == ""

- name: Make temp directory for console templates
command: mktemp -d /tmp/console-ansible-XXXXXX
register: mktemp
changed_when: False

- name: Copy admin client config
command: >
cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
become: true
changed_when: false

- name: Copy console templates to temp directory
copy:
src: "{{ item }}"
Expand All @@ -31,7 +25,7 @@
# contents so we don't overwrite changes.

- name: Read the existing console config map
shell: "{{ openshift_client_binary }} get configmap console-config -n kubevirt-web-ui -o jsonpath='{.data}' | true"
shell: "{{ openshift_client_binary }} get configmap console-config -n {{ kubevirt_web_ui_namespace }} -o jsonpath='{.data}' | true"
register: console_config_map

- set_fact:
Expand Down Expand Up @@ -68,19 +62,18 @@
register: updated_console_config

- name: Apply the console template file
become: true
shell: >
{{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __console_template_file }}"
--param IMAGE="{{ kubevirt_web_ui_image_name }}"
--param NAMESPACE="{{ kubevirt_web_ui_namespace }}"
--param NODE_SELECTOR={{ kubevirt_web_ui_nodeselector | to_json | quote }}
--param SERVER_CONFIG="{{ updated_console_config['content'] | b64decode }}"
--param REPLICA_COUNT="{{ kubevirt_web_ui_replica_count }}"
--param CONSOLE_HOSTNAME="{{ kubevirt_web_ui_hostname }}"
--param TLS_CERT="{{ console_cert | default('') }}"
--param TLS_KEY="{{ console_key | default('') }}"
--param TLS_CA_CERT="{{ console_ca_cert | default('') }}"
--config={{ mktemp.stdout }}/admin.kubeconfig
| {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
| {{ openshift_client_binary }} apply -f -
- name: Remove temp directory
file:
Expand Down
3 changes: 1 addition & 2 deletions roles/kubevirt_web_ui/tasks/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# A zero return code indicates the rollout succeeded.
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#complete-deployment
command: >
{{ openshift_client_binary }} rollout status deployment/console --config={{ openshift.common.config_base }}/master/admin.kubeconfig -n kubevirt-web-ui
{{ openshift_client_binary }} rollout status deployment/console -n {{ kubevirt_web_ui_namespace }}
changed_when: false
become: true
# deviation from openshift-ansible: fail first and let the user gather troubleshooting info manually via `oc status`, `oc get pods`, `oc get events`, and `oc logs deployment/console`

0 comments on commit 587bbca

Please sign in to comment.