Skip to content

Commit

Permalink
Merge branch 'feature/ARTESCA-7317_enable_webhook_deployment' into q/…
Browse files Browse the repository at this point in the history
…125.0
  • Loading branch information
bert-e committed Mar 29, 2023
2 parents 32c5717 + f047356 commit 6e17c24
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
installation can be done on offline environment with no DNS
(PR[#4019](https://github.com/scality/metalk8s/pull/4019))

- Add an option on solution to add a volume named `cert` to a
deployment. The volume is originally to enable webhook in
the deployment.
(PR[#4032](https://github.com/scality/metalk8s/pull/4032))

### Enhancements

- Bump Kubernetes version to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ spec:
volumeMounts:
- name: operator-config
mountPath: /etc/config
{%- if webhook_enabled is defined and webhook_enabled %}
- name: cert
mountPath: /cert
readOnly: true
{%- endif %}
volumes:
- name: operator-config
configMap:
name: {{ solution }}-operator-config
{%- if webhook_enabled is defined and webhook_enabled %}
- name: cert
secret:
defaultMode: 420
secretName: {{ solution }}-cert
{%- endif %}
2 changes: 2 additions & 0 deletions salt/metalk8s/orchestrate/solutions/prepare-environment.sls
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{%- from "metalk8s/map.jinja" import repo with context %}
{%- set env_name = pillar.orchestrate.env_name %}
{%- set webhook_enabled = pillar.orchestrate.webhook_enabled %}
{%- macro deploy_operator(namespace, name, solution) %}
Expand Down Expand Up @@ -65,6 +66,7 @@ Apply Operator Deployment for Solution {{ solution.name }}:
image_name: {{ solution.manifest.spec.operator.image.name }}
image_tag: {{ solution.manifest.spec.operator.image.tag }}
repository: {{ repo.registry_endpoint ~ '/' ~ solution.id }}
webhook_enabled: {{ webhook_enabled }}
- require:
- metalk8s_kubernetes: Apply Operator ConfigMap for Solution {{ solution.name }}
Expand Down
9 changes: 9 additions & 0 deletions salt/tests/unit/formulas/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,15 @@ metalk8s:
image_name: example-operator
image_tag: "1.2.3"

"Example Solution v1.2.3 with webhook":
extra_context:
<<: *base_context_solution_operator_files
repository: >-
metalk8s-registry-from-config.invalid/example-solution-1.2.3
image_name: example-operator-webhook
image_tag: "1.2.3"
webhook_enabled: true

role_binding.yaml.j2:
_cases:
"Example Solution v1.2.3 (see ../../prepare-environment.sls)":
Expand Down
13 changes: 10 additions & 3 deletions scripts/solutions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NAMESPACE=''
SOLUTION=''
VERBOSE=${VERBOSE:-0}
VERSION=''
WEBHOOK_ENABLED=${WEBHOOK_ENABLED:-false}

export KUBECONFIG

Expand Down Expand Up @@ -94,6 +95,7 @@ usage() {
echo " name)"
echo " -s, --solution Name of the Solution to add"
echo " -V, --version Version of the Solution to add"
echo " -w, --webhook Enable webhook validation"
echo
echo " delete-solution Delete a Solution from an Environment"
echo " -n, --name Name of the Environment to delete the"
Expand Down Expand Up @@ -122,9 +124,10 @@ LONG_OPTS='
namespace:,
solution:,
verbose,
version:
version:,
webhook,
'
SHORT_OPTS='a:d:hl:n:N:s:vV:'
SHORT_OPTS='a:d:hl:n:N:s:vV:w'

if ! options=$(getopt --options "$SHORT_OPTS" --long "$LONG_OPTS" -- "$@"); then
echo 1>&2 "Incorrect arguments provided"
Expand Down Expand Up @@ -181,6 +184,9 @@ while :; do
shift
VERSION=$1
;;
-w|--webhook)
WEBHOOK_ENABLED=true
;;
--)
shift
break
Expand Down Expand Up @@ -439,7 +445,8 @@ add_solution() {
local -ra pillar=(
"{"
" 'orchestrate': {"
" 'env_name': '$NAME'"
" 'env_name': '$NAME',"
" 'webhook_enabled': $WEBHOOK_ENABLED"
" }"
"}"
)
Expand Down

0 comments on commit 6e17c24

Please sign in to comment.