-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: External Secrets Operator Incept
- Loading branch information
1 parent
c6ea951
commit 9fba152
Showing
11 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
kubernetes/argocd/applications/external-secrets-operator.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: external-secrets-operator | ||
namespace: argocd | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "1" | ||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
labels: | ||
app.kubernetes.io/instance: argocd | ||
spec: | ||
destination: | ||
namespace: external-secrets-operator | ||
server: https://kubernetes.default.svc | ||
project: default | ||
source: | ||
path: kubernetes/external-secrets-operator/okd | ||
repoURL: https://git.arthurvardevanyan.com/ArthurVardevanyan/HomeLab | ||
targetRevision: HEAD | ||
syncPolicy: | ||
syncOptions: | ||
- CreateNamespace=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# External Secrets Operator | ||
|
||
```bash | ||
kubectl kustomize kubernetes/external-secrets-operator/overlays/okd | kubectl apply -f - | ||
``` | ||
|
||
## REF | ||
|
||
- <https://external-secrets.io/latest/provider/hashicorp-vault/#kubernetes-authentication> |
250 changes: 250 additions & 0 deletions
250
kubernetes/external-secrets-operator/base/installplan-approver.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: installplan-approvers | ||
namespace: external-secrets-operator | ||
labels: | ||
app.kubernetes.io/instance: external-secrets-operator | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: installplan-approver | ||
subjects: | ||
- kind: ServiceAccount | ||
name: installplan-approver-job | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: installplan-approver-job | ||
namespace: external-secrets-operator | ||
labels: | ||
app.kubernetes.io/instance: external-secrets-operator | ||
--- | ||
kind: Job | ||
apiVersion: batch/v1 | ||
metadata: | ||
name: installplan-approver-external-secrets-operator | ||
namespace: external-secrets-operator | ||
annotations: | ||
argocd.argoproj.io/hook: Sync | ||
argocd.argoproj.io/hook-delete-policy: HookSucceeded | ||
argocd.argoproj.io/sync-wave: "1" | ||
checkov.io/skip1: CKV_K8S_38=Need to Approve Install Plans | ||
checkov.io/skip2: CKV_K8S_40=OpenShift Injects Random UID | ||
checkov.io/skip3: CKV_K8S_43=Don't Mind Tag for This | ||
labels: | ||
app.kubernetes.io/instance: external-secrets-operator | ||
spec: | ||
parallelism: 1 | ||
backoffLimit: 0 | ||
ttlSecondsAfterFinished: 500 | ||
completionMode: NonIndexed | ||
suspend: false | ||
template: | ||
metadata: | ||
labels: | ||
app: installplan-approver | ||
spec: | ||
restartPolicy: OnFailure | ||
activeDeadlineSeconds: 300 | ||
serviceAccountName: installplan-approver-job | ||
automountServiceAccountToken: true | ||
enableServiceLinks: true | ||
terminationGracePeriodSeconds: 30 | ||
securityContext: | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault | ||
dnsPolicy: ClusterFirst | ||
containers: | ||
- name: installplan-approver | ||
imagePullPolicy: IfNotPresent | ||
image: registry.<path:secret/data/homelab/domain#url>/homelab/toolbox:not_latest | ||
env: | ||
- name: SUBSCRIPTION | ||
value: external-secrets-operator | ||
- name: SLEEP | ||
value: "15" | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
securityContext: | ||
runAsNonRoot: true | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
allowPrivilegeEscalation: false | ||
seccompProfile: | ||
type: RuntimeDefault | ||
capabilities: | ||
drop: | ||
- ALL | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 32Mi | ||
limits: | ||
cpu: 100m | ||
memory: 64Mi | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
set -o errexit # exit on any failure | ||
set -o nounset # exit on undeclared variables | ||
set -o pipefail # return value of all commands in a pipe | ||
echo "Approving Operator Install. Waiting a few seconds to make sure the InstallPlan gets Created First." | ||
sleep "${SLEEP}" | ||
echo "Processing subscription '${SUBSCRIPTION}'" | ||
export INSTALL_PLAN | ||
export STARTING_CSV | ||
export INSTALL_PLAN_VERSION | ||
export INSTALL_CSV | ||
INSTALLED_CSV=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].status.installedCSV}') | ||
STARTING_CSV=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].spec.startingCSV}') | ||
echo Installed CSV: "${INSTALLED_CSV}" | ||
echo Starting CSV: "${STARTING_CSV}" | ||
# If Installed (Current) Version equals Starting (Target) Version then Exit | ||
if [[ "${INSTALLED_CSV}" == "${STARTING_CSV}" ]]; then | ||
echo "Installed CSV and Starting CSV Identical, Exiting" | ||
exit 0 | ||
fi | ||
INSTALL_PLAN=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].status.installPlanRef.name}') | ||
INSTALL_PLAN_VERSION=$(kubectl -n "${NAMESPACE}" get installplan "${INSTALL_PLAN}" -o jsonpath="{.spec.clusterServiceVersionNames}") | ||
echo Install Plan CSV: "${INSTALL_PLAN_VERSION}" | ||
echo Starting CSV: "${STARTING_CSV}" | ||
# Check if Install Plan Version Matches Target Version, if not Exit. | ||
# Common Cause is due to attempting to skip multiple versions | ||
if [[ "${INSTALL_PLAN_VERSION}" != *"${STARTING_CSV}"* ]]; then | ||
echo "Install Plan Does Not Match Desired Version, Manual Intervention Might be Required" | ||
exit 1 | ||
fi | ||
# Approve Install Plan if Not Approved | ||
if [[ "$(kubectl -n "${NAMESPACE}" get installplan "${INSTALL_PLAN}" -o jsonpath="{.spec.approved}")" == "false" ]]; then | ||
echo "Approving Subscription ${SUBSCRIPTION} with install plan $INSTALL_PLAN" | ||
kubectl -n "${NAMESPACE}" patch installplan "${INSTALL_PLAN}" --type=json -p='[{"op":"replace","path": "/spec/approved", "value": true}]' | ||
else | ||
echo "Install Plan '$INSTALL_PLAN' already approved" | ||
fi | ||
--- | ||
kind: Job | ||
apiVersion: batch/v1 | ||
metadata: | ||
name: installplan-approver-devworkspace-operator | ||
namespace: external-secrets-operator | ||
annotations: | ||
argocd.argoproj.io/hook: Sync | ||
argocd.argoproj.io/hook-delete-policy: HookSucceeded | ||
argocd.argoproj.io/sync-wave: "1" | ||
checkov.io/skip1: CKV_K8S_38=Need to Approve Install Plans | ||
checkov.io/skip2: CKV_K8S_40=OpenShift Injects Random UID | ||
checkov.io/skip3: CKV_K8S_43=Don't Mind Tag for This | ||
labels: | ||
app.kubernetes.io/instance: external-secrets-operator | ||
spec: | ||
parallelism: 1 | ||
backoffLimit: 0 | ||
ttlSecondsAfterFinished: 500 | ||
completionMode: NonIndexed | ||
suspend: false | ||
template: | ||
metadata: | ||
labels: | ||
app: installplan-approver | ||
spec: | ||
restartPolicy: OnFailure | ||
activeDeadlineSeconds: 300 | ||
serviceAccountName: installplan-approver-job | ||
automountServiceAccountToken: true | ||
enableServiceLinks: true | ||
terminationGracePeriodSeconds: 30 | ||
securityContext: | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault | ||
dnsPolicy: ClusterFirst | ||
containers: | ||
- name: installplan-approver | ||
imagePullPolicy: IfNotPresent | ||
image: registry.<path:secret/data/homelab/domain#url>/homelab/toolbox:not_latest | ||
env: | ||
- name: SUBSCRIPTION | ||
value: devworkspace-operator | ||
- name: SLEEP | ||
value: "15" | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
securityContext: | ||
runAsNonRoot: true | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
allowPrivilegeEscalation: false | ||
seccompProfile: | ||
type: RuntimeDefault | ||
capabilities: | ||
drop: | ||
- ALL | ||
resources: | ||
requests: | ||
cpu: 10m | ||
memory: 32Mi | ||
limits: | ||
cpu: 100m | ||
memory: 64Mi | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
set -o errexit # exit on any failure | ||
set -o nounset # exit on undeclared variables | ||
set -o pipefail # return value of all commands in a pipe | ||
echo "Approving Operator Install. Waiting a few seconds to make sure the InstallPlan gets Created First." | ||
sleep "${SLEEP}" | ||
echo "Processing subscription '${SUBSCRIPTION}'" | ||
export INSTALL_PLAN | ||
export STARTING_CSV | ||
export INSTALL_PLAN_VERSION | ||
export INSTALL_CSV | ||
INSTALLED_CSV=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].status.installedCSV}') | ||
STARTING_CSV=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].spec.startingCSV}') | ||
echo Installed CSV: "${INSTALLED_CSV}" | ||
echo Starting CSV: "${STARTING_CSV}" | ||
# If Installed (Current) Version equals Starting (Target) Version then Exit | ||
if [[ "${INSTALLED_CSV}" == "${STARTING_CSV}" ]]; then | ||
echo "Installed CSV and Starting CSV Identical, Exiting" | ||
exit 0 | ||
fi | ||
INSTALL_PLAN=$(kubectl -n "${NAMESPACE}" get subscriptions.operators.coreos.com --field-selector metadata.name="${SUBSCRIPTION}" -o jsonpath='{.items[0].status.installPlanRef.name}') | ||
INSTALL_PLAN_VERSION=$(kubectl -n "${NAMESPACE}" get installplan "${INSTALL_PLAN}" -o jsonpath="{.spec.clusterServiceVersionNames}") | ||
echo Install Plan CSV: "${INSTALL_PLAN_VERSION}" | ||
echo Starting CSV: "${STARTING_CSV}" | ||
# Check if Install Plan Version Matches Target Version, if not Exit. | ||
# Common Cause is due to attempting to skip multiple versions | ||
if [[ "${INSTALL_PLAN_VERSION}" != *"${STARTING_CSV}"* ]]; then | ||
echo "Install Plan Does Not Match Desired Version, Manual Intervention Might be Required" | ||
exit 1 | ||
fi | ||
# Approve Install Plan if Not Approved | ||
if [[ "$(kubectl -n "${NAMESPACE}" get installplan "${INSTALL_PLAN}" -o jsonpath="{.spec.approved}")" == "false" ]]; then | ||
echo "Approving Subscription ${SUBSCRIPTION} with install plan $INSTALL_PLAN" | ||
kubectl -n "${NAMESPACE}" patch installplan "${INSTALL_PLAN}" --type=json -p='[{"op":"replace","path": "/spec/approved", "value": true}]' | ||
else | ||
echo "Install Plan '$INSTALL_PLAN' already approved" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ./installplan-approver.yaml | ||
- ./kyverno.yaml | ||
- ./namespace.yaml | ||
- ./operator-config.yaml | ||
- ./operator-group.yaml | ||
- ./subscription.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: replace-external-secrets-operator | ||
annotations: | ||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
argocd.argoproj.io/sync-wave: "1" | ||
spec: | ||
background: false | ||
rules: | ||
- name: replace-external-secrets-operator | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
containers: | ||
- (image): "ghcr.io/external-secrets/external-secrets-helm-operator@sha256:8792003c97d3982ad246cf6a43103d8968cd04fd126a719bc5ee49ea6248ecb3" | ||
image: "ghcr.io/external-secrets/external-secrets-helm-operator@sha256:fb433d368f2f91efc1f637de80d670445a76a3577a7c9835f8fc9ad8bc630376" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
annotations: | ||
argocd.argoproj.io/sync-wave: "0" | ||
labels: | ||
app.kubernetes.io/instance: external-secrets-operator | ||
kubernetes.io/metadata.name: external-secrets-operator | ||
name: external-secrets-operator |
Oops, something went wrong.