Skip to content

Commit 6be90b3

Browse files
authored
enable dependent resource watching (kiali#71)
* add support for k8s_status task first custom status will be the full accessible namespaces list (regex's are expanded) * watch all ns by default
1 parent 59d31d9 commit 6be90b3

File tree

7 files changed

+43
-9
lines changed

7 files changed

+43
-9
lines changed

build/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ FROM quay.io/operator-framework/ansible-operator:v0.17.0
33
COPY roles/ ${HOME}/roles/
44
COPY playbooks/ ${HOME}/playbooks/
55
COPY watches.yaml ${HOME}/watches.yaml
6+
7+
COPY requirements.yml ${HOME}/requirements.yml
8+
RUN ansible-galaxy collection install -r ${HOME}/requirements.yml \
9+
&& chmod -R ug+rwx ${HOME}/.ansible

deploy/deploy-kiali-operator.sh

+19-5
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@
120120
# Default: "false"
121121
#
122122
# OPERATOR_WATCH_NAMESPACE
123-
# The namespace in which the operator looks for the Kiali CR.
124-
# Default: The configured OPERATOR_NAMESPACE
123+
# The namespace in which the operator looks for a Kiali CR. When a Kiali CR is touched (i.e. created,
124+
# modified, or deleted) in a watched namespace, the operator will perform all necessary tasks in order
125+
# to deploy Kiali with the configuration specified in the Kiali CR (this is called "reconciling").
126+
# If specified as "**" (or, alternatively, literally two double-quotes "") then the operator will
127+
# watch all namespaces. Note that if you specify a specific watch namespace, and a user changes
128+
# some of the Kiali resources that exist outside of that watched namespace (e.g. deletes or modifies
129+
# the Kiali Deployment) the operator will be unable to reconcile those changes (e.g. it will not
130+
# be able to redeploy the Deployment resource) unless and until the Kiali CR is touched again.
131+
# Default: ""
125132
#
126133
# -----------
127134
# Environment variables that affect Kiali installation:
@@ -428,8 +435,15 @@ Valid options for the operator installation:
428435
operator will be unable to do so.
429436
Default: "false"
430437
-own|--operator-watch-namespace
431-
The namespace in which the operator looks for the Kiali CR.
432-
Default: The configured operator namespace (-on)
438+
The namespace in which the operator looks for a Kiali CR. When a Kiali CR is touched (i.e. created,
439+
modified, or deleted) in a watched namespace, the operator will perform all necessary tasks in order
440+
to deploy Kiali with the configuration specified in the Kiali CR (this is called "reconciling").
441+
If specified as "**" (or, alternatively, literally two double-quotes "") then the operator will
442+
watch all namespaces. Note that if you specify a specific watch namespace, and a user changes
443+
some of the Kiali resources that exist outside of that watched namespace (e.g. deletes or modifies
444+
the Kiali Deployment) the operator will be unable to reconcile those changes (e.g. it will not
445+
be able to redeploy the Deployment resource) unless and until the Kiali CR is touched again.
446+
Default: ""
433447
434448
Valid options for Kiali installation (if Kiali is to be installed):
435449
-an|--accessible-namespaces
@@ -569,7 +583,7 @@ export OPERATOR_NAMESPACE="${OPERATOR_NAMESPACE:-kiali-operator}"
569583
export OPERATOR_SKIP_WAIT="${OPERATOR_SKIP_WAIT:-false}"
570584
export OPERATOR_VERSION_LABEL="${OPERATOR_VERSION_LABEL:-$OPERATOR_IMAGE_VERSION}"
571585
export OPERATOR_VIEW_ONLY_MODE="${OPERATOR_VIEW_ONLY_MODE:-false}"
572-
export OPERATOR_WATCH_NAMESPACE="${OPERATOR_WATCH_NAMESPACE:-$OPERATOR_NAMESPACE}"
586+
export OPERATOR_WATCH_NAMESPACE="${OPERATOR_WATCH_NAMESPACE:-\"\"}"
573587
export OPERATOR_ROLE_CLUSTERROLEBINDINGS="# The operator does not have permission to manage cluster role bindings"
574588
export OPERATOR_ROLE_CLUSTERROLES="# The operator does not have permission to manage cluster roles"
575589
export OPERATOR_ROLE_CREATE="# The operator does not have permission to create"

deploy/merge-operator-yaml.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ $0 [option...]
9090
The value of this label is determined by this setting.
9191
Default: The value given for the operator image version
9292
-own|--operator-watch-namespace
93-
The namespace in which the operator looks for the Kiali CR.
94-
Default: The configured operator namespace (-on)
93+
The namespace in which the operator looks for the Kiali CR. If '""' then watch all namespaces.
94+
Default: ""
9595
9696
HELPMSG
9797
exit 1
@@ -109,7 +109,7 @@ export OPERATOR_IMAGE_NAME="${OPERATOR_IMAGE_NAME:-quay.io/kiali/kiali-operator}
109109
export OPERATOR_IMAGE_VERSION="${OPERATOR_IMAGE_VERSION:-latest}"
110110
export OPERATOR_IMAGE_PULL_POLICY="${OPERATOR_IMAGE_PULL_POLICY:-IfNotPresent}"
111111
export OPERATOR_NAMESPACE="${OPERATOR_NAMESPACE:-kiali-operator}"
112-
export OPERATOR_WATCH_NAMESPACE="${OPERATOR_WATCH_NAMESPACE:-${OPERATOR_NAMESPACE}}"
112+
export OPERATOR_WATCH_NAMESPACE="${OPERATOR_WATCH_NAMESPACE:-\"\"}"
113113

114114
# If version label is not specified, set it to image version; but if
115115
# image version is "latest" the version label will be set to "master".

requirements.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
collections:
2+
- community.kubernetes
3+
- operator_sdk.util

roles/default/kiali-deploy/tasks/main.yml

+5
Original file line numberDiff line numberDiff line change
@@ -842,3 +842,8 @@
842842
- processed_resources.configmap is defined
843843
- processed_resources.configmap.changed == True
844844
- processed_resources.configmap.method == "patch"
845+
846+
- include_tasks: update-status.yml
847+
vars:
848+
status_vars:
849+
accessibleNamespaces: "{{ kiali_vars.deployment.accessible_namespaces }}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- operator_sdk.util.k8s_status:
2+
api_version: "{{ current_cr.apiVersion }}"
3+
kind: "{{ current_cr.kind }}"
4+
name: "{{ current_cr.metadata.name }}"
5+
namespace: "{{ current_cr.metadata.namespace }}"
6+
status: "{{ status_vars }}"
7+
ignore_errors: yes

watches.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
kind: Kiali
55
playbook: /opt/ansible/playbooks/kiali-deploy.yml
66
reconcilePeriod: 0
7-
watchDependentResources: False
7+
watchDependentResources: True
8+
watchClusterScopedResources: True
89
finalizer:
910
name: finalizer.kiali
1011
playbook: /opt/ansible/playbooks/kiali-remove.yml

0 commit comments

Comments
 (0)