无法在Kubernertes中的一个复制控制器中使用configmap

时间:2016-09-19 14:03:42

标签: configuration kubernetes

我使用名为configmap-setenv的setenv.sh文件创建了configmap。我只想在我的一个复制控制器中使用这个configmap。

apiVersion: v1
kind: ReplicationController
metadata:
  name: sample-registrationweb-rc
spec:
  replicas: 1
  selector:
    app: "JWS"
    role: "FO-registrationweb"
    tier: "app"
  template:
    metadata:
      labels:
        app: "JWS"
        role: "FO-registrationweb"
        tier: "app"
    spec:
      containers:
      - name: jws
        image: samplejws/demo:v1
        imagePullPolicy: Always
        ports:
          - name: jws
            containerPort: 8080

        resources:
            requests:
               cpu: 1000m
               memory: 100Mi
            limits:
               cpu: 2000m
               memory: 7629Mi
        volumeMounts:
        - mountPath: /opt/soft/jws-3.0/tomcat8/bin
          name: tomcatbin
      volumes:
      - name: data
        emptyDir: {}
      - configMap:
        name: tomcatbin
          name: configmap-setenv
          items:
          - key: setenv.sh
            path: setenv.sh

我在创建复制控制器期间遇到错误。

error validating "registartion-rc.yaml": error validating data: found invalid field configMap for v1.Volume; if you choose to ignore these errors, turn validation off with --validate=false

1 个答案:

答案 0 :(得分:0)

您遇到语法错误。较新版本的 volumes: - name: tomcatbin configMap: name: configmap-setenv items: - key: setenv.sh path: setenv.sh 会为您提供更具体的错误:{{1}}

configmap卷装载应如下所示:

{{1}}