title: Kubernetes multi-container pod
body: <p>Hello I try to have a Pod with 2 container, one a c++ app, one a mysql database. I used to have the mysql deployed in its own service, but i got latency issue. So i want to try multi-container pod.</p>
  
  <p>But i've been struggling to connect my app with the mysql through localhost. It says..</p>
  
  <blockquote>
    <p>Can\'t connect to local MySQL server through socket
    \'/var/run/mysqld/mysqld.sock</p>
  </blockquote>
  
  <p>Here is my kubernetes.yaml. Please I need help :(</p>
  
  <pre><code># Database setup
  kind: StorageClass
  apiVersion: storage.k8s.io/v1
  metadata:
    name: storage-camera
    labels:     
      group: camera
  provisioner: kubernetes.io/gce-pd
  parameters:
    type: pd-ssd
  ---
  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: camera-pv
    labels:     
      group: camera
  spec:
    storageClassName: db-camera
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 20Gi
    storageClassName: storage-camera
  ---
  # Service setup
  apiVersion: v1
  kind: Service
  metadata:
    name: camera-service
    labels:
      group: camera
  spec:
    ports:
      - port: 50052
        targetPort: 50052
    selector:
      group: camera
      tier: service
    type: LoadBalancer
  ---
  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: camera-service
    labels:
      group: camera
      tier: service
  spec:
    replicas: 1
    strategy:
      type: RollingUpdate
      rollingUpdate:
        maxUnavailable: 0
        maxSurge: 1
    minReadySeconds: 60
    template:
      metadata:
        labels:
          group: camera
          tier: service
      spec:
        containers:
        - image: asia.gcr.io/test/db-camera:latest
          name: db-camera
          env:
          - name : MYSQL_ROOT_PASSWORD
            value : root
          ports:
          - containerPort: 3306
            name: mysql
          volumeMounts:
          - name: camera-persistent-storage
            mountPath: /var/lib/mysql
        - name: camera-service
          image: asia.gcr.io/test/camera-service:latest
          env:
          - name : DB_HOST
            value : "localhost"
          - name : DB_PORT
            value : "3306"
          - name : DB_NAME
            value : "camera"
          - name : DB_ROOT_PASS
            value : "password"
          ports:
          - name: http-cam
            containerPort: 50052
        volumes:
        - name: camera-persistent-storage
          persistentVolumeClaim:
            claimName: camera-pv
        restartPolicy: Always
  </code></pre>