Skip to content
Merged
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
50 changes: 3 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,57 +142,13 @@ In order to modify the deployment follow these steps:

1. Modify the GROUPS env variable to contain the list of classes (openshift groups) of which you would like to assign class labels. This file is found here: webhooks/assign-class-label/deployment.yaml

2. Generate a new OpenSSL certificate
2. Change namespace variable in the kubernetes manifests to match namespace you want the webhook to be deployed to.

```
openssl req -x509 -sha256 -newkey rsa:2048 -keyout webhook.key -out webhook.crt -days 1024 -nodes -addext "subjectAltName = DNS.1:service_name.namespace.svc"
```

When deployed to rhods-notebooks the command was specified as such:

```
openssl req -x509 -sha256 -newkey rsa:2048 -keyout webhook.key -out webhook.crt -days 1024 -nodes -addext "subjectAltName = DNS.1:assign-class-label-webhook.rhods-notebooks.svc"
```

3. Add the cert and key to the required resources:

```
cat webhook.crt | base64 | tr -d '\n'
```

```
cat webhook.key | base64 | tr -d '\n'
```

This will encode the certificate and key in base64 format which is required. Copy the output of the webhook.crt to the caBundle in webhooks/assign-class-label/webhook-config.yaml. Then create a secret.yaml that looks like this

```
apiVersion: v1
kind: Secret
metadata:
name: webhook-cert
type: Opaque
data:
webhook.crt:
webhook.key:
```

Copy and paste the output of the cat command to the respective fields for webhook.crt and webhook.key. Then execute

```
oc apply -f secret.yaml --as system:admin
```

within the same namespace that your webhook will be deployed to.


4. Change namespace variable in the kubernetes manifests to match namespace you want the webhook to be deployed to.

5. From webhooks/assign-class-label/ directory run:
3. From webhooks/assign-class-label/ directory run:
```
oc apply -k . --as system:admin
```

***Steps 2, 3, and 4 are only required if you are deploying to a new namespace/environment.***
***Step 2 is only required if you are deploying to a new namespace/environment.***

The python script and docker image used for the webserver should not need changes made to it. But in the case that changes must be made, the Dockerfile and python script can be found at docker/src/python/assign-class-label/.
12 changes: 12 additions & 0 deletions webhooks/assign-class-label/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: assign-class-label-tls
spec:
secretName: assign-class-label-tls
issuerRef:
name: assign-class-label-issuer
kind: Issuer
commonName: "rhods-notebooks.svc"
dnsNames:
- assign-class-label-webhook.rhods-notebooks.svc
13 changes: 9 additions & 4 deletions webhooks/assign-class-label/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ spec:
ports:
- containerPort: 443
volumeMounts:
- name: cert
mountPath: /certs
- name: tls
mountPath: /certs/webhook.crt
subPath: tls.crt
readOnly: true
- name: tls
mountPath: /certs/webhook.key
subPath: tls.key
readOnly: true
resources:
limits:
Expand All @@ -30,6 +35,6 @@ spec:
value: "cs210,cs599-pmpp"
serviceAccountName: webhook-sa
volumes:
- name: cert
- name: tls
secret:
secretName: webhook-cert
secretName: assign-class-label-tls
6 changes: 6 additions & 0 deletions webhooks/assign-class-label/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: assign-class-label-issuer
spec:
selfSigned: {}
3 changes: 2 additions & 1 deletion webhooks/assign-class-label/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ commonLabels:
app: assign-class-label-webhook

resources:
- issuer.yaml
- certificate.yaml
- deployment.yaml
- service.yaml
- webhook-config.yaml
- serviceaccount.yaml
- role.yaml
- rolebinding.yaml
- secret.yaml
5 changes: 3 additions & 2 deletions webhooks/assign-class-label/webhook-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: assign-class-label-webhook
annotations:
cert-manager.io/inject-ca-from: rhods-notebooks/assign-class-label-tls
webhooks:
- name: assign-class-label-webhook.nerc.com
- name: assign-class-label-webhook.rhods-notebooks.svc
client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