微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何创建使用 cdk8s 提取自定义图像的秘密?

如何解决如何创建使用 cdk8s 提取自定义图像的秘密?

我有以下课程:

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 文档没有。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。