Skip to content

Commit

Permalink
fix external secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
angryninja48 committed May 14, 2024
1 parent 30a545a commit 6aabd28
Show file tree
Hide file tree
Showing 44 changed files with 1,239 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kubernetes/apps/external-secrets/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://json.schemastore.org/kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Pre Flux-Kustomizations
- ./namespace.yaml
# Flux-Kustomizations
- ./external-secrets/ks.yaml
7 changes: 7 additions & 0 deletions kubernetes/apps/external-secrets/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: external-secrets
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
10 changes: 10 additions & 0 deletions kubernetes/apps/network/cloudflared/app/configs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
originRequest:
originServerName: "external.${SECRET_DOMAIN}"

ingress:
- hostname: "${SECRET_DOMAIN}"
service: https://ingress-nginx-external-controller.network.svc.cluster.local:443
- hostname: "*.${SECRET_DOMAIN}"
service: https://ingress-nginx-external-controller.network.svc.cluster.local:443
- service: http_status:404
10 changes: 10 additions & 0 deletions kubernetes/apps/network/cloudflared/app/dnsendpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: cloudflared
spec:
endpoints:
- dnsName: "external.${SECRET_DOMAIN}"
recordType: CNAME
targets: ["${SECRET_CLOUDFLARE_TUNNEL_ID}.cfargotunnel.com"]
110 changes: 110 additions & 0 deletions kubernetes/apps/network/cloudflared/app/helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: cloudflared
spec:
interval: 30m
chart:
spec:
chart: app-template
version: 3.1.0
sourceRef:
kind: HelmRepository
name: bjw-s
namespace: flux-system
install:
remediation:
retries: 3
upgrade:
cleanupOnFail: true
remediation:
retries: 3
values:
controllers:
cloudflared:
replicas: 2
strategy: RollingUpdate
annotations:
reloader.stakater.com/auto: "true"
containers:
app:
image:
repository: docker.io/cloudflare/cloudflared
tag: 2024.4.1
env:
NO_AUTOUPDATE: true
TUNNEL_CRED_FILE: /etc/cloudflared/creds/credentials.json
TUNNEL_METRICS: 0.0.0.0:8080
TUNNEL_ORIGIN_ENABLE_HTTP2: true
TUNNEL_TRANSPORT_PROTOCOL: quic
TUNNEL_POST_QUANTUM: true
TUNNEL_ID:
valueFrom:
secretKeyRef:
name: cloudflared-secret
key: TUNNEL_ID
args:
- tunnel
- --config
- /etc/cloudflared/config/config.yaml
- run
- "$(TUNNEL_ID)"
probes:
liveness: &probes
enabled: true
custom: true
spec:
httpGet:
path: /ready
port: &port 8080
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
readiness: *probes
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: { drop: ["ALL"] }
resources:
requests:
cpu: 10m
limits:
memory: 256Mi
defaultPodOptions:
securityContext:
runAsNonRoot: true
runAsUser: 65534
runAsGroup: 65534
seccompProfile: { type: RuntimeDefault }
service:
app:
controller: cloudflared
ports:
http:
port: *port
serviceMonitor:
app:
serviceName: cloudflared
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
persistence:
config:
type: configMap
name: cloudflared-configmap
globalMounts:
- path: /etc/cloudflared/config/config.yaml
subPath: config.yaml
readOnly: true
creds:
type: secret
name: cloudflared-secret
globalMounts:
- path: /etc/cloudflared/creds/credentials.json
subPath: credentials.json
readOnly: true
13 changes: 13 additions & 0 deletions kubernetes/apps/network/cloudflared/app/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./dnsendpoint.yaml
- ./secret.sops.yaml
- ./helmrelease.yaml
configMapGenerator:
- name: cloudflared-configmap
files:
- ./configs/config.yaml
generatorOptions:
disableNameSuffixHash: true
28 changes: 28 additions & 0 deletions kubernetes/apps/network/cloudflared/app/secret.sops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Secret
metadata:
name: cloudflared-secret
namespace: network
stringData:
TUNNEL_ID: ENC[AES256_GCM,data:ct4JXq4FwKYlXfDQCnVoXK06/Bi89hfnydOBCRheIJpvb9G0,iv:O+C4vRYivg0HSJthgcgh49is/9m/mANUwU/okhUUr4Y=,tag:XzJHO4mrtmbg63SipXYBbg==,type:str]
credentials.json: ENC[AES256_GCM,data:K44Flx1hhqgbae+St9EXkry3bqfc87EQumOmGAgudY1VC1iEziydJ6VxlKq3cleQh+8hLL2IsuaDz82l4fbwh+vgPXLDUcvuBktQDOMGB8njLWUrBBl9vtJ4w1dTL/4oewC8q+h9xVu6VOWAnTIk5rkvv27TlOCoR6emOLkDNhCPsbwOVHFxb/auNSwgRg+u5hYZH5d5mlJw/14507tW0YD7+nDgjsqFgFAOX5XQpw==,iv:HcxPjba2yVnpYwyV5R4Ye15vXLIBYAS5vsYXWdGvqfc=,tag:9gs/Sy4Knto1DXDS+gibjg==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1wvlv68u3uadfpjvluuydng2xj726pa4j5lzfzrp5z4333c2tv5fsftppun
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBMK3dnMnZVMEphaGhZUFJT
dzgyNFNpSVdJNWl0TGNCeU4veVV2VmFodTNNCmRWd1AzYWdtZCtmTm0wZEZTVzQ5
RTU5ZWFLYWdhUHFrTEd1Ym0xOTVTT2cKLS0tIE1nMTk5V0d0UWdTc2kyZ1RxZEZ2
SWl0VEd3MW9IaTlDNlJxbWFoU000NjQK7g3PCcaLxvJiiSCrtL6DM26i5261E3JC
H4BfsAeEe14SL6mJmQ7okYP2sG7zA+X1awDhZB5KiFRWRg+eX+d5/w==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-05-14T02:51:25Z"
mac: ENC[AES256_GCM,data:CV+tZAmooCiI0YtozdwbT4v+M5j6f8kO4PRzbF0zrI41gWAWyak305M0fvG4gBeTAmK9M/KetpJ3+BUgPgLwXHFyDbDz490pGpL5okShdb67fHew7spjC4GXltC5dE9OEE2mWdr/ClMJH4jG0nZ4RIIHoUbUcVoj8e7muV1jZ+g=,iv:cpN4XayKVmALhG/A5C4vUzaXYSb38G923bT10H3ZybA=,tag:xP+Jn4e3fY3rb7FJsx1XpA==,type:str]
pgp: []
encrypted_regex: ^(data|stringData)$
version: 3.8.1
22 changes: 22 additions & 0 deletions kubernetes/apps/network/cloudflared/ks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app cloudflared
namespace: flux-system
spec:
targetNamespace: network
commonMetadata:
labels:
app.kubernetes.io/name: *app
dependsOn:
- name: external-dns
path: ./kubernetes/apps/network/cloudflared/app
prune: true
sourceRef:
kind: GitRepository
name: home-kubernetes
wait: false
interval: 30m
retryInterval: 1m
timeout: 5m
91 changes: 91 additions & 0 deletions kubernetes/apps/network/echo-server/app/helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: echo-server
spec:
interval: 30m
chart:
spec:
chart: app-template
version: 3.1.0
sourceRef:
kind: HelmRepository
name: bjw-s
namespace: flux-system
install:
remediation:
retries: 3
upgrade:
cleanupOnFail: true
remediation:
retries: 3
values:
controllers:
echo-server:
strategy: RollingUpdate
containers:
app:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: 33
env:
HTTP_PORT: &port 8080
LOG_WITHOUT_NEWLINE: true
LOG_IGNORE_PATH: /healthz
PROMETHEUS_ENABLED: true
probes:
liveness: &probes
enabled: true
custom: true
spec:
httpGet:
path: /healthz
port: *port
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
readiness: *probes
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: { drop: ["ALL"] }
resources:
requests:
cpu: 10m
limits:
memory: 64Mi
defaultPodOptions:
securityContext:
runAsNonRoot: true
runAsUser: 65534
runAsGroup: 65534
seccompProfile: { type: RuntimeDefault }
service:
app:
controller: echo-server
ports:
http:
port: *port
serviceMonitor:
app:
serviceName: echo-server
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
ingress:
app:
className: external
annotations:
external-dns.alpha.kubernetes.io/target: "external.${SECRET_DOMAIN}"
hosts:
- host: "{{ .Release.Name }}.${SECRET_DOMAIN}"
paths:
- path: /
service:
identifier: app
port: http
6 changes: 6 additions & 0 deletions kubernetes/apps/network/echo-server/app/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: networking
resources:
- ./helmrelease.yaml
20 changes: 20 additions & 0 deletions kubernetes/apps/network/echo-server/ks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app echo-server
namespace: flux-system
spec:
targetNamespace: network
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/apps/network/echo-server/app
prune: true
sourceRef:
kind: GitRepository
name: home-kubernetes
wait: false
interval: 30m
retryInterval: 1m
timeout: 5m
48 changes: 48 additions & 0 deletions kubernetes/apps/network/external-dns/app/helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: &app external-dns
spec:
interval: 30m
chart:
spec:
chart: external-dns
version: 1.14.4
sourceRef:
kind: HelmRepository
name: external-dns
namespace: flux-system
install:
crds: CreateReplace
remediation:
retries: 3
upgrade:
cleanupOnFail: true
crds: CreateReplace
remediation:
strategy: rollback
retries: 3
values:
fullnameOverride: *app
provider: cloudflare
env:
- name: CF_API_TOKEN
valueFrom:
secretKeyRef:
name: external-dns-secret
key: api-token
extraArgs:
- --ingress-class=external
- --cloudflare-proxied
- --crd-source-apiversion=externaldns.k8s.io/v1alpha1
- --crd-source-kind=DNSEndpoint
policy: sync
sources: ["crd", "ingress"]
txtPrefix: k8s.
txtOwnerId: default
domainFilters: ["${SECRET_DOMAIN}"]
serviceMonitor:
enabled: true
podAnnotations:
secret.reloader.stakater.com/reload: external-dns-secret
6 changes: 6 additions & 0 deletions kubernetes/apps/network/external-dns/app/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.sops.yaml
- ./helmrelease.yaml
Loading

0 comments on commit 6aabd28

Please sign in to comment.