Skip to content

Commit

Permalink
split cert manager/flux installation from runtime chart
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Jan 5, 2024
1 parent 151e9e7 commit 58d920f
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 14 deletions.
55 changes: 55 additions & 0 deletions apps/services/runtime.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@

apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: cert-manager
namespace: infra
spec:
namespace: cert-manager
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "v1.13.3"
chart: cert-manager
valuesFiles:
- certmanager.yaml
repository:
namespace: plural-runtime
name: cert-manager
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
---
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: flux
namespace: infra
spec:
namespace: flux
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "2.12.2"
chart: flux2
valuesFiles:
- flux.yaml
repository:
namespace: plural-runtime
name: flux
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
---
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
Expand Down
3 changes: 2 additions & 1 deletion charts/runtime/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies:
condition: ingress-nginx-private.enabled
- name: flux2
repository: https://fluxcd-community.github.io/helm-charts
version: 2.12.2
version: 2.12.2
condition: flux2.enabled
50 changes: 50 additions & 0 deletions charts/runtime/templates/clusterissuers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
email: {{ .Values.ownerEmail }}
server: {{ .Values.letsencryptServer }}
privateKeySecretRef:
name: letsencryt-prod-key
solvers:
- http01:
ingress:
ingressClassName: nginx
{{ if and .Values.acmeEAB.kid .Values.dnsSolver }}
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: plural
spec:
acme:
# You must replace this email address with your own.
# Let's Encrypt will use this to contact you about expiring
# certificates, and issues related to your account.
email: {{ .Values.ownerEmail }}
server: {{ .Values.acmeServer }}
{{ if .Values.acmeEAB.kid }}
externalAccountBinding:
keyID: {{ .Values.acmeEAB.kid }}
keySecretRef:
name: acme-eab-secret
key: eab-secret
keyAlgorithm: HS256
{{ end }}
privateKeySecretRef:
# Secret resource that will be used to store the account's private key.
name: cert-manager-key
# Add a single challenge solver, dns01, configured using the appropriate cloud dns setup
solvers:
- dns01:
{{ .Values.dnsSolver | toYaml | nindent 8 }}
{{ end }}
20 changes: 16 additions & 4 deletions charts/runtime/templates/helmrepositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: bitnami
annotations:
"helm.sh/hook": post-install,post-upgrade
spec:
interval: 5m0s
type: oci
Expand All @@ -13,8 +11,22 @@ apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: flagger
annotations:
"helm.sh/hook": post-install,post-upgrade
spec:
interval: 5m0s
url: https://flagger.app
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: cert-manager
spec:
interval: 5m0s
url: https://charts.jetstack.io
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: flux
spec:
interval: 5m0s
url: https://fluxcd-community.github.io/helm-charts
4 changes: 0 additions & 4 deletions charts/runtime/templates/operator-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: plural-operator-selfsigned-issuer
annotations:
"helm.sh/hook": post-install,post-upgrade
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: plural-operator-serving-cert
annotations:
"helm.sh/hook": post-install,post-upgrade
spec:
dnsNames:
- plural-operator-webhook-service.{{ .Release.Namespace }}.svc
Expand Down
2 changes: 0 additions & 2 deletions charts/runtime/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: plural-operator
annotations:
"helm.sh/hook": post-install,post-upgrade
labels:
control-plane: plural-operator
{{- include "runtime.labels" . | nindent 4 }}
Expand Down
3 changes: 2 additions & 1 deletion charts/runtime/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dnsSolver:
acmeEAB: {}

cert-manager:
enabled: true
enabled: false
installCRDs: true
serviceAccount:
name: cert-manager
Expand Down Expand Up @@ -210,6 +210,7 @@ ingress-nginx-private:
enabled: false

flux2:
enabled: false
helmController:
create: false
imageAutomationController:
Expand Down
6 changes: 6 additions & 0 deletions helm/certmanager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
installCRDs: true
serviceAccount:
name: cert-manager
securityContext:
fsGroup: 1000
runAsNonRoot: true
14 changes: 14 additions & 0 deletions helm/flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
helmController:
create: false
imageAutomationController:
create: false
imageReflectionController:
create: false
kustomizeController:
create: false
notificationController:
create: false
sourceController:
create: true
policies:
create: false
44 changes: 42 additions & 2 deletions templates/setup/console.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
data "local_sensitive_file" "certmanager" {
filename = "${path.module}/../helm-values/certmanager.yaml"
}

resource "helm_release" "certmanager" {
name = "cert-manager"
namespace = "cert-manager"
chart = "cert-manager"
repository = "https://charts.jetstack.io"
version = "v1.13.3"
create_namespace = true
timeout = 300
wait = true
values = [
data.local_sensitive_file.certmanager.content
]

depends_on = [ module.mgmt.cluster ]
}

data "local_sensitive_file" "flux" {
filename = "${path.module}/../helm-values/flux.yaml"
}

resource "helm_release" "flux" {
name = "flux"
namespace = "flux"
chart = "flux"
repository = "https://fluxcd-community.github.io/helm-charts"
version = "2.12.2"
create_namespace = true
timeout = 300
wait = false
values = [
data.local_sensitive_file.flux.content
]

depends_on = [ module.mgmt.cluster ]
}

data "local_sensitive_file" "runtime" {
filename = "${path.module}/../helm-values/runtime.yaml"
}
Expand All @@ -7,15 +47,15 @@ resource "helm_release" "runtime" {
namespace = "plural-runtime"
chart = "runtime"
repository = "https://pluralsh.github.io/bootstrap"
version = "0.1.10"
version = "0.1.11"
create_namespace = true
timeout = 300
wait = false
values = [
data.local_sensitive_file.console.content
]

depends_on = [ module.mgmt.cluster ]
depends_on = [ module.mgmt.cluster, helm_release.certmanager, helm_release.flux ]
}

resource "null_resource" "console" {
Expand Down

0 comments on commit 58d920f

Please sign in to comment.