Skip to content

Instantly share code, notes, and snippets.

@leadelngalame1611
Created January 20, 2022 14:31
Show Gist options
  • Save leadelngalame1611/a9eadf512eb023e29dae4a4c4771cef8 to your computer and use it in GitHub Desktop.
Save leadelngalame1611/a9eadf512eb023e29dae4a4c4771cef8 to your computer and use it in GitHub Desktop.
const appLabel = { app: "hello-kubernetes" };
const deployment = {
apiVersion: "apps/v1",
kind: "Deployment",
metadata: { name: "hello-kubernetes" },
spec: {
replicas: 3,
selector: { matchLabels: appLabel },
template: {
metadata: { labels: appLabel },
spec: {
containers: [
{
name: "hello-kubernetes",
image: "paulbouwer/hello-kubernetes:1.5",
ports: [ { containerPort: 8080 } ]
}
]
}
}
}
};
const service = {
apiVersion: "v1",
kind: "Service",
metadata: { name: "hello-kubernetes" },
spec: {
type: "LoadBalancer",
ports: [ { port: 80, targetPort: 8080 } ],
selector: appLabel
}
};
// option 1: use a construct
new KubernetesResource(this, 'hello-kub', {
cluster,
manifest: [ deployment, service ]
});
// or, option2: use `addResource`
cluster.addResource('hello-kub', service, deployment);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment