-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add webhook certificate handling for k8s #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,72 @@ make deploy-setup | |
|
||
If you are running a Kubernetes cluster: | ||
```bash | ||
export OPERATOR_EXEC=kubectl | ||
export ENABLE_ADMISSION_CONTROLLER=false | ||
make deploy-setup-k8s | ||
``` | ||
|
||
Webhooks are disabled when deploying on a Kubernetes cluster as per the instructions above. To enable webhooks on Kubernetes cluster, there are two options: | ||
|
||
1. Create certificates for each of the two webhooks using a single CA whose cert you provide through an environment variable. | ||
|
||
For example, given `cacert.pem`, `key.pem` and `cert.pem`: | ||
```bash | ||
kubectl create ns sriov-network-operator | ||
kubectl -n sriov-network-operator create secret tls operator-webhook-service --cert=cert.pem --key=key.pem | ||
jcaamano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kubectl -n sriov-network-operator create secret tls network-resources-injector-secret --cert=cert.pem --key=key.pem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be able to inject the secret, do we need this annotation in the secret?:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this option is assuming the users are creating the certificates manually and cert-manager is not being used. |
||
export ENABLE_ADMISSION_CONTROLLER=true | ||
export WEBHOOK_CA_BUNDLE=$(base64 -w 0 < cacert.pem) | ||
make deploy-setup-k8s | ||
``` | ||
|
||
2. Using https://cert-manager.io/, deploy it as: | ||
```bash | ||
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.0/cert-manager.yaml | ||
``` | ||
|
||
Define the appropriate Issuer and Certificates, as an example: | ||
```bash | ||
kubectl create ns sriov-network-operator | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: cert-manager.io/v1 | ||
kind: Issuer | ||
metadata: | ||
name: sriov-network-operator-selfsigned-issuer | ||
namespace: sriov-network-operator | ||
spec: | ||
selfSigned: {} | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: operator-webhook-service | ||
namespace: sriov-network-operator | ||
spec: | ||
secretName: operator-webhook-service | ||
dnsNames: | ||
- operator-webhook-service.sriov-network-operator.svc | ||
issuerRef: | ||
name: sriov-network-operator-selfsigned-issuer | ||
--- | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: network-resources-injector-service | ||
namespace: sriov-network-operator | ||
spec: | ||
secretName: network-resources-injector-secret | ||
dnsNames: | ||
- network-resources-injector-service.sriov-network-operator.svc | ||
issuerRef: | ||
name: sriov-network-operator-selfsigned-issuer | ||
EOF | ||
``` | ||
|
||
And then deploy the operator: | ||
```bash | ||
export ENABLE_ADMISSION_CONTROLLER=true | ||
make deploy-setup-k8s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Got the following error when tried this method on a fresh k8 cluster. I made sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange, this is working for me. The secret There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tried again and working for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's working for me too on a fresh k8s install There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worked on a fresh install. Thanks! |
||
``` | ||
|
||
By default, the operator will be deployed in namespace 'sriov-network-operator' for Kubernetes cluster, you can check if the deployment is finished successfully. | ||
|
||
```bash | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the docs on cert manager and I am wondering, why not use this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That requires creating the secrets manually with a specific annotation which would be an actual extra step on all the procedure. It's is primarily used when bootstrapping cert-manager itself. After that, cert-manager creates the secrets from certificates for you so all you can directly annotate the certificate and save that extra step.