Skip to content

Agent Mesh

setup config

Antonio Ojea233fa66ef8ef
diff --git a/.github/k8s/cert-sync-cronjob-template.yaml b/.github/k8s/cert-sync-cronjob-template.yaml
new file mode 100644
index 00000000..da125227
--- /dev/null
+++ b/.github/k8s/cert-sync-cronjob-template.yaml
@@ -0,0 +1,84 @@
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: cert-sync-sa
+ namespace: sam-hub
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
+metadata:
+ name: cert-reader
+ namespace: sam-${ENV_NAME}
+rules:
+- apiGroups: [""]
+ resources: ["secrets"]
+ resourceNames: ["hub-sam-mesh-tls"]
+ verbs: ["get"]
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: cert-sync-read-binding
+ namespace: sam-${ENV_NAME}
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: cert-reader
+subjects:
+- kind: ServiceAccount
+ name: cert-sync-sa
+ namespace: sam-hub
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
+metadata:
+ name: cert-writer
+ namespace: sam-hub
+rules:
+- apiGroups: [""]
+ resources: ["secrets"]
+ verbs: ["get", "create", "delete"]
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: cert-sync-write-binding
+ namespace: sam-hub
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: cert-writer
+subjects:
+- kind: ServiceAccount
+ name: cert-sync-sa
+ namespace: sam-hub
+---
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+ name: cert-sync-cronjob
+ namespace: sam-hub
+spec:
+ schedule: "0 0 * * *" # Run daily at midnight
+ concurrencyPolicy: Forbid
+ successfulJobsHistoryLimit: 1
+ failedJobsHistoryLimit: 3
+ jobTemplate:
+ spec:
+ template:
+ spec:
+ serviceAccountName: cert-sync-sa
+ restartPolicy: OnFailure
+ containers:
+ - name: sync-agent
+ image: bitnami/kubectl:latest
+ command:
+ - /bin/sh
+ - -c
+ - |
+ echo "Fetching latest wildcard TLS secret from sam-${ENV_NAME} namespace..."
+ kubectl delete secret hub-sam-mesh-tls -n sam-hub --ignore-not-found
+ kubectl get secret hub-sam-mesh-tls -n sam-${ENV_NAME} -o yaml | \
+ sed "s/namespace: sam-${ENV_NAME}/namespace: sam-hub/" | \
+ kubectl create -f -
+ echo "Certificate successfully synchronized!"
diff --git a/.github/k8s/google-public-ca-issuer-template.yaml b/.github/k8s/google-public-ca-issuer-template.yaml
new file mode 100644
index 00000000..f28add9a
--- /dev/null
+++ b/.github/k8s/google-public-ca-issuer-template.yaml
@@ -0,0 +1,20 @@
+apiVersion: cert-manager.io/v1
+kind: Issuer
+metadata:
+ name: google-public-ca-issuer
+ namespace: ${NAMESPACE}
+spec:
+ acme:
+ server: https://dv.acme-v02.api.pki.goog/directory
+ email: "${ACME_EMAIL}"
+ privateKeySecretRef:
+ name: google-ca-account-key
+ externalAccountBinding:
+ keyID: "${EAB_KEY_ID}"
+ keySecretRef:
+ name: google-ca-eab-secret
+ key: secret
+ solvers:
+ - dns01:
+ cloudDNS:
+ project: ${GCP_PROJECT_ID}
diff --git a/.github/k8s/wildcard-cert-template.yaml b/.github/k8s/wildcard-cert-template.yaml
new file mode 100644
index 00000000..ceec88e3
--- /dev/null
+++ b/.github/k8s/wildcard-cert-template.yaml
@@ -0,0 +1,14 @@
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+ name: hub-sam-mesh-cert
+ namespace: ${NAMESPACE}
+spec:
+ secretName: hub-sam-mesh-tls
+ issuerRef:
+ name: google-public-ca-issuer
+ kind: Issuer
+ commonName: "*.sam-mesh.dev"
+ dnsNames:
+ - "*.sam-mesh.dev"
+ - "sam-mesh.dev"
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
index 93fc5efb..976c2d43 100644
--- a/.github/workflows/deploy.yaml
+++ b/.github/workflows/deploy.yaml
@@ -172,6 +172,17 @@ jobs:
echo "sam-hub-secret already exists in namespace ${NAMESPACE}. Skipping generation."
fi
+ - name: Copy Wildcard TLS Secret to sam-hub
+ run: |
+ export ENV_NAME="${{ vars.ENV_NAME }}"
+ export NAMESPACE="sam-${ENV_NAME}"
+ if [[ "${NAMESPACE}" == "sam-hub" ]]; then
+ kubectl delete secret hub-sam-mesh-tls -n sam-hub --ignore-not-found
+ kubectl get secret hub-sam-mesh-tls -n sam-bananas -o yaml | \
+ sed 's/namespace: sam-bananas/namespace: sam-hub/' | \
+ kubectl create -f -
+ fi
+
- name: Deploy Hub
run: |
sudo apt-get install -y gettext-base