Created
November 14, 2019 23:24
Revisions
-
lblackstone created this gist
Nov 14, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ // Define the application configuration and secrets. const configs = new kx.ConfigMap("app-config", { data: { "config": "very important data" } }); const secrets = new kx.Secret("app-secrets", { stringData: { "app-password": new kx.RandomPassword("app-password"), "database-password": config.databasePassword } }); // Define the application Pod. const appConfigPath = "/app/config"; const appPod = new kx.PodBuilder({ containers: [ { image: "app:1.0.0", env: { "APP_CONFIG_PATH": appConfigPath, "APP_USER": config.user, "APP_PASSWORD": secrets.asEnvValue("app-password"), "APP_DATABASE_PASSWORD": secrets.asEnvValue("database-password"), }, volumeMounts: [ configs.mount(appConfigPath) ], } ] }); // Create a Kubernetes Deployment using the previous Pod definition. const deployment = new kx.Deployment("nginx", { spec: appPod.asDeploymentSpec( { replicas: 3 } ), }); // Expose the Deployment with a load balancer using a Kubernetes Service. const service = deployment.createService({type: kx.types.ServiceType.LoadBalancer}); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ apiVersion: v1 kind: ConfigMap data: config: very important data metadata: name: app-config --- apiVersion: v1 kind: Secret data: app-password: JikkMz9mK2hIRDo3 database-password: Y29uZmlnLmRhdGFiYXNlUGFzc3dvcmQ= metadata: name: app-secrets type: Opaque --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - env: - name: APP_CONFIG_PATH value: /app/config - name: APP_USER value: config.user - name: APP_PASSWORD valueFrom: secretKeyRef: key: app-password name: app-secrets - name: APP_DATABASE_PASSWORD valueFrom: secretKeyRef: key: database-password name: app-secrets image: nginx imagePullPolicy: Always name: nginx ports: - containerPort: 80 name: http volumeMounts: - mountPath: /app/config name: app-config restartPolicy: Always volumes: - configMap: name: app-config name: app-config --- apiVersion: v1 kind: Service metadata: name: nginx spec: ports: - name: http port: 80 targetPort: 80 selector: app: nginx type: LoadBalancer