1 部署yaml文件
1.1 Deployment部署
apiVersion: apps/v1
kind: Deployment
metadata:
  name: zscore
  namespace: wangzy-p
  labels:
    app: zscore-dep
spec:
  replicas: 1
  selector:
    matchLabels:
      app: zscore
  template:
    metadata:
      labels:
        app: zscore
      annotations:
        sidecar.istio.io/inject: "false"  #如果有istio,取消sidebar注入
    spec:
      containers:
      - name: zscore
        image: registry.cn-hangzhou.aliyuncs.com/rory/kubeflow1:zscore-v1
        ports:
        - containerPort: 5006
        imagePullPolicy: Always
        command: ["/bin/bash","-c"]
        args: ["bash deploy.sh && sleep infinity"]
 
1.2 Service部署
apiVersion: v1
kind: Service
metadata:
  name: zscore-svc
  namespace: wangzy-p
spec:
  type: NodePort
  selector:
    app: zscore
  ports:
    - port: 5006
      targetPort: 5006
      nodePort: 32352
 
2 常见问题:
2.1 k8s中command、args和dockerfile中entrypoint、cmd之间的作用
- 如果command和args均没有写,那么用DockerFile默认的配置。
 - 如果command写了,但args没有写,那么Docker默认的配置会被忽略而且仅仅执行.yaml文件的command(不带任何参数的)。
 - 如果command没写,但args写了,那么Docker默认配置的ENTRYPOINT的命令行会被执行,但是调用的参数是.yaml中的args。
 - 如果如果command和args都写了,那么Docker默认的配置被忽略,使用.yaml的配置。
 
2.2 /bin/bash -c 的意思
-c 在 bash 手册中的解释:
 -c string If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
也就是说,-c 命令表示后面的参数将会作为字符串读入作为执行的命令。
举个例子,尝试在本地执行下面两个命令:
/bin/bash -c ls
/bin/bash ls
 

 可以看到, /bin/bash -c 后面接 命令 ,而 /bin/bash 后面接 执行的脚本。
参考资料:
 https://www.jianshu.com/p/bb8e9d366a5c
![[工业互联-9]:EtherCAT(以太网控制自动化技术)+TwinCAT 在生产自动化控制中的应用 、](https://img-blog.csdnimg.cn/img_convert/e0577f550f4f2f21de14fce49860fe0f.png)
![Android 源码 AOSP版本– 下载[Ubuntu ]](https://img-blog.csdnimg.cn/00c43e2701c74c6f9cfc7a7b6a5a4615.png#pic_center)













