From b30ad0dc618f53909ac9e744087e4bf679675790 Mon Sep 17 00:00:00 2001 From: "Bradon Kanyid (rattboi)" Date: Tue, 14 May 2024 00:05:33 +0000 Subject: [PATCH] Add localstack to reference implementation This adds localstack, which involves the following: 1) Install localstack as argo application This needs patching as the helm chart doesn't expose enough to access DNS port. I used kustomize + helmCharts directive in order to do a service patch. That required... 2) --enable-helm added to argocd, via configmap. 3) Delegation of localstack DNS to the localstack service, via Coredns Corefile 4) Add a new Crossplane ProviderConfig for localstack This should all be non-breaking changes One further enhancement I'll be working on is making the providerconfig selectable in the backstage template, so that a user can select between targetting localstack or aws proper when generating their app + bucket. --- .../coredns/manifests/cm-coredns.yaml | 6 ++++ ...nfig.yaml => provider-config-default.yaml} | 0 .../provider-config-localstack.yaml | 19 ++++++++++++ examples/ref-implementation/localstack.yaml | 22 ++++++++++++++ .../localstack/kustomization.yaml | 30 +++++++++++++++++++ .../localstack/service-patch.yaml | 17 +++++++++++ .../localbuild/resources/argo/install.yaml | 1 + 7 files changed, 95 insertions(+) rename examples/ref-implementation/crossplane-providers/{provider-config.yaml => provider-config-default.yaml} (100%) create mode 100644 examples/ref-implementation/crossplane-providers/provider-config-localstack.yaml create mode 100644 examples/ref-implementation/localstack.yaml create mode 100644 examples/ref-implementation/localstack/kustomization.yaml create mode 100644 examples/ref-implementation/localstack/service-patch.yaml diff --git a/examples/ref-implementation/coredns/manifests/cm-coredns.yaml b/examples/ref-implementation/coredns/manifests/cm-coredns.yaml index 9cf733ae..12890a54 100644 --- a/examples/ref-implementation/coredns/manifests/cm-coredns.yaml +++ b/examples/ref-implementation/coredns/manifests/cm-coredns.yaml @@ -31,3 +31,9 @@ data: reload loadbalance } + + localhost.localstack.cloud:53 { + errors + cache 30 + forward . 10.96.100.10 + } diff --git a/examples/ref-implementation/crossplane-providers/provider-config.yaml b/examples/ref-implementation/crossplane-providers/provider-config-default.yaml similarity index 100% rename from examples/ref-implementation/crossplane-providers/provider-config.yaml rename to examples/ref-implementation/crossplane-providers/provider-config-default.yaml diff --git a/examples/ref-implementation/crossplane-providers/provider-config-localstack.yaml b/examples/ref-implementation/crossplane-providers/provider-config-localstack.yaml new file mode 100644 index 00000000..d35faa9b --- /dev/null +++ b/examples/ref-implementation/crossplane-providers/provider-config-localstack.yaml @@ -0,0 +1,19 @@ +apiVersion: aws.crossplane.io/v1beta1 +kind: ProviderConfig +metadata: + name: localstack + annotations: + argocd.argoproj.io/sync-wave: "20" + argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true +spec: + credentials: + source: Secret + secretRef: + namespace: crossplane-system + name: local-secret + key: creds + endpoint: + hostnameImmutable: true + url: + type: Static + static: http://localhost.localstack.cloud:4566 diff --git a/examples/ref-implementation/localstack.yaml b/examples/ref-implementation/localstack.yaml new file mode 100644 index 00000000..bfd50a60 --- /dev/null +++ b/examples/ref-implementation/localstack.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: localstack + namespace: argocd + labels: + example: ref-implementation +spec: + project: default + source: + repoURL: cnoe://localstack + targetRevision: HEAD + path: "." + destination: + namespace: localstack + server: "https://kubernetes.default.svc" + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/examples/ref-implementation/localstack/kustomization.yaml b/examples/ref-implementation/localstack/kustomization.yaml new file mode 100644 index 00000000..ca91bb83 --- /dev/null +++ b/examples/ref-implementation/localstack/kustomization.yaml @@ -0,0 +1,30 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: localstack + +helmCharts: +- name: localstack + valuesInline: + debug: true + extraEnvVars: + - name: DEFAULT_REGION + value: "us-east-1" + dnsPolicy: "Default" + service: + type: ClusterIP + # Coredns needs a static IP to refer to for delegation + clusterIP: 10.96.100.10 + # this effectively disables the external service ports, which can be used for OpenSearch and a few other services + # these don't play well with the services kustomize patch at this point + # see https://docs.localstack.cloud/references/external-ports/ for more details + externalServicePorts: + start: 4510 + end: 4510 + dnsService: true + releaseName: localstack + repo: 'https://localstack.github.io/helm-charts' + version: 0.6.12 + +patches: +- path: service-patch.yaml diff --git a/examples/ref-implementation/localstack/service-patch.yaml b/examples/ref-implementation/localstack/service-patch.yaml new file mode 100644 index 00000000..83ab4241 --- /dev/null +++ b/examples/ref-implementation/localstack/service-patch.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: localstack +spec: + ports: + - name: edge + port: 4566 + targetPort: 4566 + - name: dns-tcp + port: 53 + targetPort: 53 + protocol: TCP + - name: dns-udp + port: 53 + targetPort: 53 + protocol: UDP diff --git a/pkg/controllers/localbuild/resources/argo/install.yaml b/pkg/controllers/localbuild/resources/argo/install.yaml index 5422ef9e..7c2d1ef8 100644 --- a/pkg/controllers/localbuild/resources/argo/install.yaml +++ b/pkg/controllers/localbuild/resources/argo/install.yaml @@ -21082,6 +21082,7 @@ subjects: apiVersion: v1 data: application.resourceTrackingMethod: annotation + kustomize.buildOptions: --enable-helm resource.exclusions: | - kinds: - ProviderConfigUsage