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

Update webhook failurePolicy from Ignore to Fail #1784

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/test-charmed-katib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ jobs:
juju bundle deploy --build --destructive-mode --serial
juju wait -wvt 300

kubectl label namespace kubeflow katib-metricscollector-injection=enabled

- name: Test Katib
run: kubectl apply -f examples/v1beta1/hp-tuning/random.yaml

Expand Down
3 changes: 0 additions & 3 deletions manifests/v1beta1/components/webhook/webhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
webhooks:
- name: validator.experiment.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
admissionReviewVersions:
- v1
clientConfig:
Expand All @@ -32,7 +31,6 @@ metadata:
webhooks:
- name: defaulter.experiment.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
admissionReviewVersions:
- v1
clientConfig:
Expand All @@ -53,7 +51,6 @@ webhooks:
- experiments
- name: mutator.pod.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
Copy link
Member

@tenzen-y tenzen-y Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @knkski !
I think that we need to specify Ignore in mutator.pod.katib.kubeflow.org since the katib-cert-generator job generates a Pod before the certificate is injected into MutatingWebhookConfiguration.

admissionReviewVersions:
- v1
clientConfig:
Expand Down
1 change: 1 addition & 0 deletions operators/bundle.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: katib
bundle: kubernetes
applications:
katib-controller: { charm: katib-controller, scale: 1 }
Expand Down
1 change: 1 addition & 0 deletions operators/charmcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type: bundle
3 changes: 2 additions & 1 deletion operators/katib-controller/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ops==1.2.0
jinja2<3.1
oci-image==1.0.0
ops==1.2.0
13 changes: 12 additions & 1 deletion operators/katib-controller/src/charm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python3

import logging
from base64 import b64encode
from pathlib import Path
from subprocess import check_call

import yaml
from jinja2 import Environment, FileSystemLoader
from oci_image import OCIImageResource, OCIImageResourceError
from ops.charm import CharmBase
from ops.framework import StoredState
Expand Down Expand Up @@ -49,7 +51,16 @@ def set_pod_spec(self, event):
self.model.unit.status = check_failed.status
return

validating, mutating = yaml.safe_load_all(Path("src/webhooks.yaml").read_text())
ca_bundle = b64encode(self._stored.cert.encode("utf-8")).decode("utf-8")
env = Environment(loader=FileSystemLoader("src"))
t = env.get_template("webhooks.yaml.j2")
rendered = t.render(
ca_bundle=ca_bundle,
name=self.model.app.name,
namespace=self.model.name,
port=self.model.config["webhook-port"],
)
validating, mutating = yaml.safe_load_all(rendered)

self.model.pod.set_spec(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
webhooks:
- name: validator.experiment.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
# TODO (andreyvelich): Migrate to v1 ?
admissionReviewVersions:
- v1beta1
clientConfig:
caBundle: Cg==
caBundle: {{ ca_bundle }}
service:
name: katib-controller
namespace: kubeflow
name: {{ name }}
namespace: {{ namespace }}
port: {{ port }}
path: /validate-experiment
rules:
- apiGroups:
Expand All @@ -33,14 +33,14 @@ metadata:
webhooks:
- name: defaulter.experiment.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
admissionReviewVersions:
- v1beta1
clientConfig:
caBundle: Cg==
caBundle: {{ ca_bundle }}
service:
name: katib-controller
namespace: kubeflow
name: {{ name }}
namespace: {{ namespace }}
port: {{ port }}
path: /mutate-experiment
rules:
- apiGroups:
Expand All @@ -54,14 +54,14 @@ webhooks:
- experiments
- name: mutator.pod.katib.kubeflow.org
sideEffects: None
failurePolicy: Ignore
admissionReviewVersions:
- v1beta1
clientConfig:
caBundle: Cg==
caBundle: {{ ca_bundle }}
service:
name: katib-controller
namespace: kubeflow
name: {{ name }}
namespace: {{ namespace }}
port: {{ port }}
path: /mutate-pod
namespaceSelector:
matchLabels:
Expand Down
2 changes: 1 addition & 1 deletion operators/katib-ui/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ops==1.2.0
oci-image==1.0.0
serialized-data-interface==0.2.2
serialized-data-interface<0.4