Search code examples
google-kubernetes-engineopen-policy-agent

Multiple containers within same pod on google kubernetes engine


I want to deploy OPA with my application as a side car container on google k8s engine.so need help to find out the steps I should follow and Are there any example blogs which I can find this out??


Solution

  • What you are referring to is a side car container. This is not specific to GKE and can be done on any k8s cluster. Your pod spec will include a list of containers (one for the main application and at least one sidecar) and will look something like this:

    spec:
      containers:
      - image: <my_main_app>:v1.1.2
        name: myApp
      - image: <sidecar_container>:latest
        name: sidecar_app
    

    Note that all the containers within the same pod share a network namespace so the containers cannot be assigned the same ports. Otherwise, feel free to add multiple containers to the pod (kube-dns is a good example of this)