简体   繁体   English

Kubernetes中的Pod启动命令

[英]Pods start command in kubernetes

I would like to add the docker command --user $(id -u):$(id -g) to my k8s deployment definition. 我想将docker命令--user $(id -u):$(id -g)到我的k8s部署定义中。 What is the equivalent for that in k8s? k8s中的等效值是多少?

args or command? 参数或命令?

How the container gets started normally: 容器如何正常启动:

docker run -d -p 5901:5901 -p 6901:6901 --user $(id -u):$(id -g) khwhahn/daedalus:0.1

k8s deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose --file docker-compose.yaml convert
    kompose.version: 1.10.0 (8bb0907)
  creationTimestamp: null
  labels:
    io.kompose.service: daedalus
  name: daedalus
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: daedalus
    spec:
      containers:
      - env:
        - name: DISPLAY
        image: khwhahn/daedalus:0.1
        imagePullPolicy: Always
        ports:
          - containerPort: 5901
            name: vnc
            protocol: TCP
          - containerPort: 6901
            name: http
            protocol: TCP
        livenessProbe:
            httpGet:
              path: /
              port: 6901
              scheme: HTTP
            initialDelaySeconds: 10
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /
            port: 6901
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 1
          periodSeconds: 10
          successThreshold: 1
          failureThreshold: 3
        name: daedalus
        resources: {}
        volumeMounts:
        - mountPath: /tmp/.X11-unix
          name: daedalus-claim0
        - mountPath: /home/daedalus/daedalus/tls
          name: cardano-tls
      restartPolicy: Always
      volumes:
      - name: daedalus-claim0
        persistentVolumeClaim:
          claimName: daedalus-claim0
      - name: cardano-tls
        persistentVolumeClaim:
          claimName: cardano-tls
status: {}

Thanks 谢谢

That was requested initially in kubernetes issue 22179 . 最初在kubernetes问题22179对此进行了请求。

Implemented partially in: 部分实现于:

PodSecurityContext allows Kubernetes users to specify RunAsUser which can be overriden by RunAsUser in SecurityContext on a per Container basis. PodSecurityContext允许Kubernetes用户指定RunAsUser,RunAsUser可以在每个容器中在SecurityContext中覆盖RunAsUser。

Introduce a new API field in SecurityContext and PodSecurityContext called RunAsGroup . 在SecurityContext和PodSecurityContext中引入一个名为RunAsGroup的新API字段。

See " Configure a Security Context for a Pod or Container ". 请参阅“ 为Pod或容器配置安全上下文 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM