Inter-process communication

1. Create a pod with 2 containers

ipc.yaml

apiVersion: v1
kind: Pod
metadata:
  name: mc2
spec:
  containers:
  - name: producer
    image: allingeek/ch6_ipc
    command: ["./ipc", "-producer"]
  - name: consumer
    image: allingeek/ch6_ipc
    command: ["./ipc", "-consumer"]
  restartPolicy: Never

2. Create the pods using

kubectl create -f ipc.yaml

3. Get the pods

hadoop@k8s-00:~$ kubectl get pods
NAME      READY     STATUS      RESTARTS   AGE
mc2       0/2       Completed   0          2m

4. Check the logs to verify that the 2nd container got all messages from 1st container

  • producer log
hadoop@k8s-00:~$ kubectl logs mc2 -c producer
Produced: 5
Produced: ba
Produced: 2d
Produced: 65
Produced: be
Produced: f
Produced: 44
Produced: 6f
Produced: 23
Produced: b0
Produced: ca
Produced: 21
Produced: fa
Produced: 75
Produced: 79
Produced: a6
Produced: b3
  • consumer log
hadoop@k8s-00:~$ kubectl logs mc2 -c consumer
Consumed: 5
Consumed: ba
Consumed: 2d
Consumed: 65
Consumed: be
Consumed: f
Consumed: 44
Consumed: 6f
Consumed: 23
Consumed: b0
Consumed: ca
Consumed: 21
Consumed: fa
Consumed: 75
Consumed: 79
Consumed: a6
Consumed: b3
Consumed: 7c
Consumed: done

results matching ""

    No results matching ""