我有以下课程:
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 无法正常工作,因为我无法从我的私有存储库中拉取图像(docker pull 有效),因为服务中的 pod 因无法拉取图像而到处抛出错误。我该如何解决这个问题?
还有一件事,如果有人知道,您能指出我应该在哪里查看如何将卷附加到这些 pod 吗?本地卷我的意思是,CDK8S 文档没有。