Skip to content

Commit

Permalink
be able to add containers to Kiali pod
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed May 2, 2022
1 parent aa1daf3 commit a5de7d1
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 160 deletions.
1 change: 1 addition & 0 deletions crd-docs/cr/kiali.io_v1alpha1_kiali.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:

deployment:
accessible_namespaces: ["^((?!(istio-operator|kube-.*|openshift.*|ibm.*|kiali-operator)).)*$"]
additional_pod_containers_yaml: {}
# default: additional_service_yaml is empty
additional_service_yaml:
externalName: "kiali.example.com"
Expand Down
4 changes: 4 additions & 0 deletions crd-docs/crd/kiali.io_kialis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ spec:
type: array
items:
type: string
additional_pod_containers_yaml:
description: "Additional containers to add to the list of pod containers. Use this to add a sidecar(s) to the Kiali pod. Use with care since sidecars may cause the Kiali container itself to operate incorrectly. It is up to the user who added the additional containers to ensure it works properly inside the Kiali pod; Kiali makes no guarantee additional containers will work."
type: object
x-kubernetes-preserve-unknown-fields: true
additional_service_yaml:
description: "Additional custom yaml to add to the service definition. This is used mainly to customize the service type. For example, if the `deployment.service_type` is set to 'LoadBalancer' and you want to set the loadBalancerIP, you can do so here with: `additional_service_yaml: { 'loadBalancerIP': '78.11.24.19' }`. Another example would be if the `deployment.service_type` is set to 'ExternalName' you will need to configure the name via: `additional_service_yaml: { 'externalName': 'my.kiali.example.com' }`. A final example would be if external IPs need to be set: `additional_service_yaml: { 'externalIPs': ['80.11.12.10'] }`"
type: object
Expand Down
1 change: 1 addition & 0 deletions roles/default/kiali-deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ kiali_defaults:

deployment:
accessible_namespaces: ["^((?!(istio-operator|kube-.*|openshift.*|ibm.*|kiali-operator)).)*$"]
additional_pod_containers_yaml: {}
#additional_service_yaml:
affinity:
node: {}
Expand Down
162 changes: 2 additions & 160 deletions roles/default/kiali-deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,166 +90,8 @@
- kiali_vars.deployment.ingress_enabled is defined
- kiali_vars.deployment.ingress is not defined or kiali_vars.deployment.ingress.enabled is not defined

# Because we are passing through some yaml directly to Kubernetes resources, we have to retain the camelCase keys.
# All CR parameters are converted to snake_case, but the original yaml is found in the special _kiali_io_kiali param.
# We need to copy that original yaml into our vars where appropriate to keep the camelCase.

- name: Replace snake_case with camelCase in deployment.affinity.node
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('node') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'node': current_cr.spec.deployment.affinity.node }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.node is defined
- kiali_vars.deployment.affinity.node | length > 0

- name: Replace snake_case with camelCase in deployment.affinity.pod
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('pod') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'pod': current_cr.spec.deployment.affinity.pod }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.pod is defined
- kiali_vars.deployment.affinity.pod | length > 0

- name: Replace snake_case with camelCase in deployment.affinity.pod_anti
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('pod_anti') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'pod_anti': current_cr.spec.deployment.affinity.pod_anti }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.pod_anti is defined
- kiali_vars.deployment.affinity.pod_anti | length > 0

- name: Replace snake_case with camelCase in deployment.tolerations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('tolerations') %}
{{ kiali_vars | combine({'deployment': {'tolerations': current_cr.spec.deployment.tolerations }}, recursive=True) }}
when:
- kiali_vars.deployment.tolerations is defined
- kiali_vars.deployment.tolerations | length > 0

- name: Replace snake_case with camelCase in deployment.additional_service_yaml
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('additional_service_yaml') %}
{{ kiali_vars | combine({'deployment': {'additional_service_yaml': current_cr.spec.deployment.additional_service_yaml }}, recursive=True) }}
when:
- kiali_vars.deployment.additional_service_yaml is defined
- kiali_vars.deployment.additional_service_yaml | length > 0

- name: Replace snake_case with camelCase in deployment.resources
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('resources') %}
{{ kiali_vars | combine({'deployment': {'resources': current_cr.spec.deployment.resources }}, recursive=True) }}
when:
- kiali_vars.deployment.resources is defined
- kiali_vars.deployment.resources | length > 0

- name: Replace snake_case with camelCase in deployment.ingress.override_yaml
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['ingress'].pop('override_yaml') %}
{{ kiali_vars | combine({'deployment': {'ingress': {'override_yaml': current_cr.spec.deployment.ingress.override_yaml }}}, recursive=True) }}
when:
- kiali_vars.deployment.ingress.override_yaml is defined
- kiali_vars.deployment.ingress.override_yaml | length > 0

- name: Replace snake_case with camelCase in deployment.pod_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('pod_annotations') %}
{{ kiali_vars | combine({'deployment': {'pod_annotations': current_cr.spec.deployment.pod_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.pod_annotations is defined
- kiali_vars.deployment.pod_annotations | length > 0

- name: Replace snake_case with camelCase in deployment.pod_labels
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('pod_labels') %}
{{ kiali_vars | combine({'deployment': {'pod_labels': current_cr.spec.deployment.pod_labels }}, recursive=True) }}
when:
- kiali_vars.deployment.pod_labels is defined
- kiali_vars.deployment.pod_labels | length > 0

- name: Replace snake_case with camelCase in deployment.service_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('service_annotations') %}
{{ kiali_vars | combine({'deployment': {'service_annotations': current_cr.spec.deployment.service_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.service_annotations is defined
- kiali_vars.deployment.service_annotations | length > 0

- name: Replace snake_case with camelCase in deployment.hpa.spec
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['hpa'].pop('spec') %}
{{ kiali_vars | combine({'deployment': {'hpa': {'spec': current_cr.spec.deployment.hpa.spec }}}, recursive=True) }}
when:
- kiali_vars.deployment.hpa is defined
- kiali_vars.deployment.hpa.spec is defined
- kiali_vars.deployment.hpa.spec | length > 0

- name: Replace snake_case with camelCase in deployment.node_selector
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('node_selector') %}
{{ kiali_vars | combine({'deployment': {'node_selector': current_cr.spec.deployment.node_selector }}, recursive=True) }}
when:
- kiali_vars.deployment.node_selector is defined
- kiali_vars.deployment.node_selector | length > 0

- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.custom_headers
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('custom_headers') %}
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'custom_headers': current_cr.spec.external_services.custom_dashboards.prometheus.custom_headers }}}}, recursive=True) }}
when:
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers is defined
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers | length > 0

- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.query_scope
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('query_scope') %}
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'query_scope': current_cr.spec.external_services.custom_dashboards.prometheus.query_scope }}}}, recursive=True) }}
when:
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope is defined
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope | length > 0

- name: Replace snake_case with camelCase in external_services.prometheus.custom_headers
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['prometheus'].pop('custom_headers') %}
{{ kiali_vars | combine({'external_services': {'prometheus': {'custom_headers': current_cr.spec.external_services.prometheus.custom_headers }}}, recursive=True) }}
when:
- kiali_vars.external_services.prometheus.custom_headers is defined
- kiali_vars.external_services.prometheus.custom_headers | length > 0

- name: Replace snake_case with camelCase in external_services.prometheus.query_scope
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['prometheus'].pop('query_scope') %}
{{ kiali_vars | combine({'external_services': {'prometheus': {'query_scope': current_cr.spec.external_services.prometheus.query_scope }}}, recursive=True) }}
when:
- kiali_vars.external_services.prometheus.query_scope is defined
- kiali_vars.external_services.prometheus.query_scope | length > 0

- name: Replace snake_case with camelCase in deployment.configmap_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('configmap_annotations') %}
{{ kiali_vars | combine({'deployment': {'configmap_annotations': current_cr.spec.deployment.configmap_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.configmap_annotations is defined
- kiali_vars.deployment.configmap_annotations | length > 0
# convert snake case to camelCase where appropriate
- include_tasks: snake_camel_case.yaml

- name: Print some debug information
vars:
Expand Down
169 changes: 169 additions & 0 deletions roles/default/kiali-deploy/tasks/snake_camel_case.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Because we are passing through some yaml directly to Kubernetes resources, we have to retain the camelCase keys.
# All CR parameters are converted to snake_case, but the original yaml is found in the special _kiali_io_kiali param.
# We need to copy that original yaml into our vars where appropriate to keep the camelCase.

- name: Replace snake_case with camelCase in deployment.affinity.node
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('node') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'node': current_cr.spec.deployment.affinity.node }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.node is defined
- kiali_vars.deployment.affinity.node | length > 0

- name: Replace snake_case with camelCase in deployment.affinity.pod
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('pod') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'pod': current_cr.spec.deployment.affinity.pod }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.pod is defined
- kiali_vars.deployment.affinity.pod | length > 0

- name: Replace snake_case with camelCase in deployment.affinity.pod_anti
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['affinity'].pop('pod_anti') %}
{{ kiali_vars | combine({'deployment': {'affinity': {'pod_anti': current_cr.spec.deployment.affinity.pod_anti }}}, recursive=True) }}
when:
- kiali_vars.deployment.affinity is defined
- kiali_vars.deployment.affinity.pod_anti is defined
- kiali_vars.deployment.affinity.pod_anti | length > 0

- name: Replace snake_case with camelCase in deployment.tolerations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('tolerations') %}
{{ kiali_vars | combine({'deployment': {'tolerations': current_cr.spec.deployment.tolerations }}, recursive=True) }}
when:
- kiali_vars.deployment.tolerations is defined
- kiali_vars.deployment.tolerations | length > 0

- name: Replace snake_case with camelCase in deployment.additional_service_yaml
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('additional_service_yaml') %}
{{ kiali_vars | combine({'deployment': {'additional_service_yaml': current_cr.spec.deployment.additional_service_yaml }}, recursive=True) }}
when:
- kiali_vars.deployment.additional_service_yaml is defined
- kiali_vars.deployment.additional_service_yaml | length > 0

- name: Replace snake_case with camelCase in deployment.resources
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('resources') %}
{{ kiali_vars | combine({'deployment': {'resources': current_cr.spec.deployment.resources }}, recursive=True) }}
when:
- kiali_vars.deployment.resources is defined
- kiali_vars.deployment.resources | length > 0

- name: Replace snake_case with camelCase in deployment.ingress.override_yaml
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['ingress'].pop('override_yaml') %}
{{ kiali_vars | combine({'deployment': {'ingress': {'override_yaml': current_cr.spec.deployment.ingress.override_yaml }}}, recursive=True) }}
when:
- kiali_vars.deployment.ingress.override_yaml is defined
- kiali_vars.deployment.ingress.override_yaml | length > 0

- name: Replace snake_case with camelCase in deployment.pod_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('pod_annotations') %}
{{ kiali_vars | combine({'deployment': {'pod_annotations': current_cr.spec.deployment.pod_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.pod_annotations is defined
- kiali_vars.deployment.pod_annotations | length > 0

- name: Replace snake_case with camelCase in deployment.pod_labels
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('pod_labels') %}
{{ kiali_vars | combine({'deployment': {'pod_labels': current_cr.spec.deployment.pod_labels }}, recursive=True) }}
when:
- kiali_vars.deployment.pod_labels is defined
- kiali_vars.deployment.pod_labels | length > 0

- name: Replace snake_case with camelCase in deployment.service_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('service_annotations') %}
{{ kiali_vars | combine({'deployment': {'service_annotations': current_cr.spec.deployment.service_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.service_annotations is defined
- kiali_vars.deployment.service_annotations | length > 0

- name: Replace snake_case with camelCase in deployment.hpa.spec
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment']['hpa'].pop('spec') %}
{{ kiali_vars | combine({'deployment': {'hpa': {'spec': current_cr.spec.deployment.hpa.spec }}}, recursive=True) }}
when:
- kiali_vars.deployment.hpa is defined
- kiali_vars.deployment.hpa.spec is defined
- kiali_vars.deployment.hpa.spec | length > 0

- name: Replace snake_case with camelCase in deployment.node_selector
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('node_selector') %}
{{ kiali_vars | combine({'deployment': {'node_selector': current_cr.spec.deployment.node_selector }}, recursive=True) }}
when:
- kiali_vars.deployment.node_selector is defined
- kiali_vars.deployment.node_selector | length > 0

- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.custom_headers
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('custom_headers') %}
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'custom_headers': current_cr.spec.external_services.custom_dashboards.prometheus.custom_headers }}}}, recursive=True) }}
when:
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers is defined
- kiali_vars.external_services.custom_dashboards.prometheus.custom_headers | length > 0

- name: Replace snake_case with camelCase in external_services.custom_dashboards.prometheus.query_scope
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['custom_dashboards']['prometheus'].pop('query_scope') %}
{{ kiali_vars | combine({'external_services': {'custom_dashboards': {'prometheus': {'query_scope': current_cr.spec.external_services.custom_dashboards.prometheus.query_scope }}}}, recursive=True) }}
when:
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope is defined
- kiali_vars.external_services.custom_dashboards.prometheus.query_scope | length > 0

- name: Replace snake_case with camelCase in external_services.prometheus.custom_headers
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['prometheus'].pop('custom_headers') %}
{{ kiali_vars | combine({'external_services': {'prometheus': {'custom_headers': current_cr.spec.external_services.prometheus.custom_headers }}}, recursive=True) }}
when:
- kiali_vars.external_services.prometheus.custom_headers is defined
- kiali_vars.external_services.prometheus.custom_headers | length > 0

- name: Replace snake_case with camelCase in external_services.prometheus.query_scope
set_fact:
kiali_vars: |
{% set a=kiali_vars['external_services']['prometheus'].pop('query_scope') %}
{{ kiali_vars | combine({'external_services': {'prometheus': {'query_scope': current_cr.spec.external_services.prometheus.query_scope }}}, recursive=True) }}
when:
- kiali_vars.external_services.prometheus.query_scope is defined
- kiali_vars.external_services.prometheus.query_scope | length > 0

- name: Replace snake_case with camelCase in deployment.configmap_annotations
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('configmap_annotations') %}
{{ kiali_vars | combine({'deployment': {'configmap_annotations': current_cr.spec.deployment.configmap_annotations }}, recursive=True) }}
when:
- kiali_vars.deployment.configmap_annotations is defined
- kiali_vars.deployment.configmap_annotations | length > 0

- name: Replace snake_case with camelCase in deployment.additional_pod_containers_yaml
set_fact:
kiali_vars: |
{% set a=kiali_vars['deployment'].pop('additional_pod_containers_yaml') %}
{{ kiali_vars | combine({'deployment': {'additional_pod_containers_yaml': current_cr.spec.deployment.additional_pod_containers_yaml }}, recursive=True) }}
when:
- kiali_vars.deployment.additional_pod_containers_yaml is defined
- kiali_vars.deployment.additional_pod_containers_yaml | length > 0
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ spec:
{{ kiali_vars.deployment.resources | to_nice_yaml(indent=0) | trim | indent(10) }}
{% else %}
resources: null
{% endif %}
{% if kiali_vars.deployment.additional_pod_containers_yaml|length > 0 %}
{{ kiali_vars.deployment.additional_pod_containers_yaml | to_nice_yaml(indent=0) | trim | indent(6) }}
{% endif %}
volumes:
- name: kiali-configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ spec:
{{ kiali_vars.deployment.resources | to_nice_yaml(indent=0) | trim | indent(10) }}
{% else %}
resources: null
{% endif %}
{% if kiali_vars.deployment.additional_pod_containers_yaml|length > 0 %}
{{ kiali_vars.deployment.additional_pod_containers_yaml | to_nice_yaml(indent=0) | trim | indent(6) }}
{% endif %}
volumes:
- name: kiali-configuration
Expand Down

0 comments on commit a5de7d1

Please sign in to comment.