core: refactor webhook config and related script

This commit refactor webhook config by adding/removing
spaces. Also, moved the Issue and Certificate creation
from bash script to webhook config yaml.

Signed-off-by: subhamkrai <srai@redhat.com>
This commit is contained in:
subhamkrai committed 2022-03-14 10:16:01 +05:30
1 parent 536a73af64
commit 2115daa317
2 files changed
+40 -45

No files matched your search

+5 -33
View File
@@ -81,38 +81,10 @@ EOF
echo "Successfully deployed cert-manager"
echo "Creating Issuer and Certificate"
cat <<EOF | kubectl create -f -
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: ${NAMESPACE}
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: rook-admission-controller-cert
namespace: ${NAMESPACE}
spec:
dnsNames:
- ${SERVICE_NAME}
- ${SERVICE_NAME}.${NAMESPACE}.svc
- ${SERVICE_NAME}.${NAMESPACE}.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: rook-ceph-admission-controller
EOF
echo "Successfully created Issuer and Certificate"
echo "Creating Issuer, Certificate and Deploying webhook config"
echo "Deploying webhook config"
< "${BASE_DIR}"/webhook-config.yaml \
sed -e "s|\${NAMESPACE}|${NAMESPACE}|g" | \
sed -e "s|\${WEBHOOK_CONFIG_NAME}|${WEBHOOK_CONFIG_NAME}|g" | \
sed -e "s|\${SERVICE_NAME}|${SERVICE_NAME}|g" | \
kubectl create -f -
envsubst < "${BASE_DIR}"/webhook-config.yaml |
kubectl create -f -
echo "Webhook deployed! Please start the rook operator to create the service and admission controller pods"
+35 -12
View File
@@ -1,3 +1,26 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: ${NAMESPACE}
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: rook-admission-controller-cert
namespace: ${NAMESPACE}
spec:
dnsNames:
- ${SERVICE_NAME}
- ${SERVICE_NAME}.${NAMESPACE}.svc
- ${SERVICE_NAME}.${NAMESPACE}.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: rook-ceph-admission-controller
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
@@ -7,43 +30,43 @@ metadata:
webhooks:
- name: cephcluster-wh-${SERVICE_NAME}-${NAMESPACE}.rook.io
rules:
- apiGroups: ["ceph.rook.io"]
- apiGroups: ["ceph.rook.io"]
apiVersions: ["v1"]
operations: ["CREATE","UPDATE","DELETE"]
resources: ["cephclusters"]
operations: ["CREATE", "UPDATE", "DELETE"]
resources: ["cephclusters"]
clientConfig:
service:
name: ${SERVICE_NAME}
namespace: ${NAMESPACE}
path: /validate-ceph-rook-io-v1-cephcluster
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
sideEffects: None
timeoutSeconds: 5
- name: cephblockpool-wh-${SERVICE_NAME}-${NAMESPACE}.rook.io
rules:
- apiGroups: ["ceph.rook.io"]
- apiGroups: ["ceph.rook.io"]
apiVersions: ["v1"]
operations: ["CREATE","UPDATE","DELETE"]
resources: ["cephblockpools"]
operations: ["CREATE", "UPDATE", "DELETE"]
resources: ["cephblockpools"]
clientConfig:
service:
name: ${SERVICE_NAME}
namespace: ${NAMESPACE}
path: /validate-ceph-rook-io-v1-cephblockpool
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
sideEffects: None
timeoutSeconds: 5
- name: cephobjectstore-wh-${SERVICE_NAME}-${NAMESPACE}.rook.io
rules:
- apiGroups: ["ceph.rook.io"]
- apiGroups: ["ceph.rook.io"]
apiVersions: ["v1"]
operations: ["CREATE","UPDATE","DELETE"]
resources: ["cephobjectstores"]
operations: ["CREATE", "UPDATE", "DELETE"]
resources: ["cephobjectstores"]
clientConfig:
service:
name: ${SERVICE_NAME}
namespace: ${NAMESPACE}
path: /validate-ceph-rook-io-v1-cephobjectstore
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
admissionReviewVersions: ["v1", "v1beta1"] # API server will try to use first version in the list which it supports.
sideEffects: None
timeoutSeconds: 5