一個容器多個進程,一個pod多個容器


  1. 一個容器多個進程:在Docker的鏡像編譯腳本Dockerfile中帶起多個進程,如下可以在contivNet.sh中啟動多個進程
FROM 192.168.1.2:5001/world/centos7/ovs-2.6.4:1


COPY ./bin /contiv/bin/
COPY ./scripts /contiv/scripts/

ENTRYPOINT ["/contiv/scripts/contivNet.sh"]
  1. 一個pod多個容器,可以在yaml文件中如下設置,在containers 中定義兩個容器
# each master and worker node in a Kubernetes cluster.
kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
  name: contiv-netplugin-ovs
  namespace: kube-system
  labels:
    k8s-app: contiv-netplugin
spec:
  updateStrategy:
    type: OnDelete
  selector:
    matchLabels:
      k8s-app: contiv-netplugin
  template:
    metadata:
      labels:
        k8s-app: contiv-netplugin
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '9004'
        scheduler.alpha.kubernetes.io/critical-pod: ''
    spec:
      hostNetwork: true
      hostPID: true
      nodeSelector:
        node-role.kubernetes.io/node: ""
        node-network-driver: "ovs"
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      serviceAccountName: contiv-netplugin
      containers:
        - name: netplugin-exporter
          image: 192.168.1.2:5001/contiv/exporter:0.1
          env:
            - name: CONTIV_ETCD
              valueFrom:
                configMapKeyRef:
                  name: contiv-config
                  key: contiv_etcd
            - name: CONTIV_ROLE
              value: 'ovs-netplugin'
          volumeMounts:
            - mountPath: /k8s_log/contiv
              name: var-log-contiv-exporter
              readOnly: false
        - name: contiv-netplugin
          image: 192.168.1.2:5001/contiv/netplugin:1.2.0_6.3
          env:
            - name: CONTIV_ROLE
              value: netplugin
            - name: CONTIV_NETPLUGIN_VLAN_UPLINKS
              value: enp130s0f0
            - name: CONTIV_NETPLUGIN_DRIVER
              value: ovs
            - name: CONTIV_NETPLUGIN_LOG_LEVEL
              value: INFO
            - name: CONTIV_NETPLUGIN_MODE
              valueFrom:
                configMapKeyRef:
                  name: contiv-config
                  key: contiv_mode
            - name: CONTIV_NETPLUGIN_VTEP_IP
              valueFrom:

可以在每個容器中啟動一個進程,例如可以使用command啟動進程:

 command:
 - /bin/sh
 - -c
 - /kubemark --morph=kubelet --name=$(NODE_NAME)  --kubeconfig=/kubeconfig/kubelet-$(NODE_NAME).kubeconfig $(CONTENT_TYPE) --alsologtostderr --v=4

這樣一個pod中啟動了兩個容器,每個容器啟動了一個進程。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM