使用istio在Kubernetes上运行mongodb有状态集

时间:2018-10-29 04:47:06

标签: kubernetes google-kubernetes-engine kubernetes-statefulset

我正在尝试使用istio在kubernetes上设置mongodb。我的状态集如下:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: treeservice
  namespace: staging
spec:
  serviceName: tree-service-service
  replicas: 1
  selector:
    matchLabels:
      app: treeservice
  template:
    metadata:
      labels:
        app: treeservice
    spec:
      containers:
      - name: mongodb-cache
        image: mongo:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 30010
        volumeMounts:
        - name: mongodb-cache-data
          mountPath: /data/db
        resources:
          requests:
            memory: "4Gi" # 4 GB
            cpu: "1000m"  # 1 CPUs
          limits:
            memory: "4Gi" # 4 GB
            cpu: "1000" #  1 CPUs    
        readinessProbe: 
          exec:
            command:
            - mongo
            - --eval "db.stats()" --port 30010
          initialDelaySeconds: 60 #wait this period after staring fist time
          periodSeconds: 30    # polling interval every 5 minutes
          timeoutSeconds: 60 
        livenessProbe: 
          exec:
            command:
            - mongo
            - --eval "db.stats()" --port 30010
          initialDelaySeconds: 60 #wait this period after staring fist time
          periodSeconds: 30    # polling interval every 5 minutes
          timeoutSeconds: 60   
        command: ["/bin/bash"]
        args: ["-c","mongod --port 30010 --replSet test"] #bind to localhost
  volumeClaimTemplates:
  - metadata:
      name: mongodb-cache-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: fast
      resources:
        requests:
          storage: 300Gi

但是,未创建广告连播,并且看到以下错误:

kubectl describe statefulset treeservice -n staging

Warning  FailedCreate  1m (x159 over 1h)  statefulset-controller  create Pod treeservice-0 in StatefulSet treeservice failed error: Pod "treeservice-0" is invalid: spec.containers[1].env[7].name: Invalid value: "ISTIO_META_statefulset.kubernetes.io/pod-name": a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name',  or 'MY_ENV.NAME',  or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')      

我假设treeservice是有效的广告连播名称。我想念什么吗?

1 个答案:

答案 0 :(得分:3)

我想这是由于此问题https://github.com/istio/istio/issues/9571仍未解决

我通过以下方法使其暂时可用:

annotations:
        sidecar.istio.io/inject: "false"
相关问题