Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one create a multi-container application in helm charts?

I have not seen any documentation of a multi-container pod application on helm charts. Can anyone point on how to do this?

Something like this https://linchpiner.github.io/k8s-multi-container-pods.html or https://www.mirantis.com/blog/multi-container-pods-and-container-communication-in-kubernetes/

So basically have a pod with multiple containers.

Does helm charts support this?

UPDATE: I have been able to deploy pod now using this help (finally sample pod definition)

https://github.com/helm/charts/blob/master/stable/keycloak/templates/test/test-pod.yaml

but how do i have replicas like increase number of pods i launch kind of like deployment.yaml file?

like image 861
uberrebu Avatar asked Mar 05 '23 07:03

uberrebu


1 Answers

It should be supported in the templates essentially use the templates with multiple containers in the Pod spec. That Pod spec can also be in other abstractions like Deployments, DaemonSets, StatefulSets, etc.

Example:

https://github.com/helm/charts/blob/master/stable/mysql/templates/deployment.yaml https://github.com/helm/charts/blob/master/stable/lamp/templates/deployment.yaml

and a few more here:

https://github.com/helm/charts/tree/master/stable

You can scale your deployment replicas like this:

kubectl scale deployment mysql-deployment --replicas=10

More on that here

On the template you can specify replicas in the deployment spec.

For example:

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: my-dep
  namespace: kube-system
  labels:
    k8s-app: my-app
spec:
  replicas: 1   <= here
  selector:
    matchLabels:
      k8s-app: my-app
  template:
    metadata:
      labels:
        k8s-app: my-app
        name: my-app
    spec:
      serviceAccountName: mysa
      terminationGracePeriodSeconds: 60
      containers:
      - image: mycontainer
        name: myappcontainer
        ports:
        - name: http
          containerPort: 80
        - name: admin
          containerPort: 8080
        args:
        - --opt1
        - --opt2
        - --opt3
      - image: mycontainer2
        name: myappcontainer2
like image 101
Rico Avatar answered Apr 05 '23 20:04

Rico