I have the following class:
import { KubeDeployment, KubeSecret, KubeService } from './imports/k8s';
import { Construct } from 'constructs';
import { App, Chart } from 'cdk8s';
import * as kplus from 'cdk8s-plus-17';
class MyChart extends Chart {
constructor(scope: Construct, name: string) {
super(scope, name);
const label = { app: 'simple-nginx-server' };
this.createDeployment(label);
this.createService(label);
this.createSecret(label);
}
createDeployment(label: any) {
new KubeDeployment(this, 'deployment', {
spec: {
replicas: 5,
selector: {
matchLabels: label
},
template: {
metadata: { labels: label },
spec: {
containers: [
{
name: 'webserver',
image: 'myrepo/myimage',
imagePullPolicy: kplus.ImagePullPolicy.IF_NOT_PRESENT,
ports: [{ containerPort: 80 }]
}
]
}
}
}
});
}
createService(label: any) {
new KubeService(this, 'service', {
spec: {
type: 'LoadBalancer',
ports: [{ port: 80, targetPort: 80 }],
selector: label
}
});
}
createSecret(label: any) {
new KubeSecret(this, 'secret', {
metadata: { labels: label }, data: { "auths": "base64auth" }, type: "kubernetes.io/dockerconfigjson"
});
}
}
const app = new App();
new MyChart(app, 'nginx-custom-server');
app.synth();
The Secret is not working correctly because I cannot pull the image from my private repository (docker pull works), because the pods from the services throw errors all over the place, due to not being able to pull the image. How may I fix this?
One more thing, if anyone knows can you point me to where I should look on how to attach volumes to these pods? Local volumes I mean, CDK8S documentation does not have it.