Created
July 14, 2025 13:39
-
-
Save bgdnlp/4e2a2e5f176245c81d2dc7fa322b14af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| --- | |
| apiVersion: fluxcd.controlplane.io/v1 | |
| kind: ResourceSetInputProvider | |
| metadata: | |
| name: voting-app | |
| labels: | |
| inputsFor: generic-app-db | |
| spec: | |
| type: Static | |
| defaultValues: | |
| tenantName: othertenant | |
| projectName: voting-app | |
| applications: | |
| - name: voting-app-result | |
| image: ghcr.io/dockersamples/example-voting-app-result | |
| replicas: 1 | |
| containerPort: 80 | |
| serviceType: NodePort | |
| servicePort: 8001 | |
| nodePort: 31011 | |
| - name: voting-app-vote | |
| image: ghcr.io/dockersamples/example-voting-app-vote | |
| replicas: 1 | |
| containerPort: 80 | |
| serviceType: NodePort | |
| nodePort: 31010 | |
| - name: voting-app-worker | |
| image: ghcr.io/dockersamples/example-voting-app-worker | |
| replicas: 1 | |
| containerPort: 80 | |
| databases: | |
| postgresql: | |
| - name: voting-app-db | |
| replicas: 1 | |
| serviceName: db # must be "db" | |
| redis: | |
| - name: voting-app-cache | |
| replicas: 1 | |
| serviceName: redis # must be "redis" | |
| --- | |
| apiVersion: fluxcd.controlplane.io/v1 | |
| kind: ResourceSetInputProvider | |
| metadata: | |
| name: podinfo | |
| labels: | |
| inputsFor: generic-app-db | |
| spec: | |
| type: Static | |
| defaultValues: | |
| tenantName: othertenant | |
| projectName: podinfo | |
| applications: | |
| - name: podinfo | |
| image: ghcr.io/stefanprodan/podinfo | |
| replicas: 1 | |
| containerPort: 9898 | |
| serviceType: NodePort | |
| nodePort: 30098 | |
| databases: | |
| redis: | |
| - name: podinfo-cache | |
| replicas: 1 | |
| serviceName: cache | |
| --- | |
| apiVersion: fluxcd.controlplane.io/v1 | |
| kind: ResourceSet | |
| metadata: | |
| name: generic-app-db | |
| spec: | |
| inputsFrom: | |
| - kind: ResourceSetInputProvider | |
| selector: | |
| matchLabels: | |
| inputsFor: generic-app-db | |
| resourcesTemplate: | | |
| # APPLICATIONS | |
| <<- range $applications := get inputs "applications" | default list >> | |
| --- | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: << $applications.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $applications.name >> | |
| spec: | |
| replicas: << $applications.replicas >> | |
| selector: | |
| matchLabels: | |
| app.kubernetes.io/name: << $applications.name >> | |
| template: | |
| metadata: | |
| labels: | |
| app.kubernetes.io/name: << $applications.name >> | |
| spec: | |
| containers: | |
| - image: << $applications.image >> | |
| name: << $applications.name >> | |
| ports: | |
| - containerPort: << $applications.containerPort >> | |
| name: containerport | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: << get $applications "serviceName" | default $applications.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $applications.name >> | |
| spec: | |
| type: << get $applications "serviceType" | default "ClusterIP" >> | |
| ports: | |
| - name: << $applications.name >> | |
| # port exposed by the service inside the cluster | |
| port: << get $applications "servicePort" | default $applications.containerPort >> | |
| # pod port, the port the application is running on. Can be the port's name | |
| targetPort: << $applications.containerPort >> | |
| <<- if eq (get $applications "serviceType" | default "ClusterIP") "NodePort" >> | |
| # port on each node, for external access | |
| nodePort: << get $applications "nodePort" | default $applications.containerPort >> | |
| <<- end >> | |
| selector: | |
| app.kubernetes.io/name: << $applications.name >> | |
| <<- end >> | |
| # POSTGRESQL | |
| <<- range $postgresql := dig "databases" "postgresql" list inputs >> | |
| --- | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: << $postgresql.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $postgresql.name >> | |
| spec: | |
| replicas: << $postgresql.replicas >> | |
| selector: | |
| matchLabels: | |
| app.kubernetes.io/name: << $postgresql.name >> | |
| template: | |
| metadata: | |
| labels: | |
| app.kubernetes.io/name: << $postgresql.name >> | |
| spec: | |
| containers: | |
| - name: postgres | |
| image: public.ecr.aws/docker/library/postgres:15-alpine | |
| env: | |
| - name: POSTGRES_USER | |
| value: postgres | |
| - name: POSTGRES_PASSWORD | |
| value: postgres | |
| ports: | |
| - containerPort: 5432 | |
| name: postgres | |
| volumeMounts: | |
| - mountPath: /var/lib/postgresql/data | |
| name: db-data | |
| volumes: | |
| - name: db-data | |
| emptyDir: {} | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: << get $postgresql "serviceName" | default $postgresql.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $postgresql.name >> | |
| spec: | |
| type: ClusterIP | |
| ports: | |
| - name: "db-service" | |
| port: 5432 | |
| targetPort: 5432 | |
| selector: | |
| app.kubernetes.io/name: << $postgresql.name >> | |
| <<- end >> | |
| # REDIS | |
| <<- range $redis := dig "databases" "redis" list inputs >> | |
| --- | |
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: << $redis.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $redis.name >> | |
| spec: | |
| replicas: << $redis.replicas >> | |
| selector: | |
| matchLabels: | |
| app.kubernetes.io/name: << $redis.name >> | |
| template: | |
| metadata: | |
| labels: | |
| app.kubernetes.io/name: << $redis.name >> | |
| spec: | |
| containers: | |
| - name: redis | |
| image: public.ecr.aws/docker/library/redis:alpine | |
| ports: | |
| - containerPort: 6379 | |
| name: redis | |
| volumeMounts: | |
| - mountPath: /data | |
| name: redis-data | |
| volumes: | |
| - name: redis-data | |
| emptyDir: {} | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: << get $redis "serviceName" | default $redis.name >> | |
| namespace: << inputs.tenantName >> | |
| labels: | |
| app.kubernetes.io/name: << $redis.name >> | |
| spec: | |
| type: ClusterIP | |
| ports: | |
| - name: "redis-service" | |
| port: 6379 | |
| targetPort: 6379 | |
| selector: | |
| app.kubernetes.io/name: << $redis.name >> | |
| <<- end >> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment