Running a custom docker image on GKE

0 votes
I want to use my custom docker image that I build on my machine on GKE. How can I do that?
Sep 18, 2018 in Kubernetes by Atul
• 5,530 points
338 views

1 answer to this question.

0 votes

You'll have tom push your image to Google Container Registry and then refer it form your pod manifest.

Make sure that your DOCKER_HOST is setup properly, your Google Container Engine is running the latest version kubernetes and you have Google Cloud SDK installed.

  1. Setting environment variables

    gcloud components update kubectl
    gcloud config set project <your-project>
    gcloud config set compute/zone <your-cluster-zone>
    gcloud config set container/cluster <your-cluster-name>
    gcloud container clusters get-credentials <your-cluster-name>
    
  2. Tagging image

    docker tag <your-image> gcr.io/<your-project>/<your-image>
    
  3. Push it on the registry

    gcloud docker push gcr.io/<your-project>/<your-image>
    
  4. Pod manifest for your container: my-pod.yaml

    id: my-pod
    kind: Pod
    apiVersion: v1
    desiredState:
      manifest:
        containers:
        - name: <container-name>
          image: gcr.io/<your-project>/<your-image>
        ...
    
  5. Schedule pod

    kubectl create -f my-pod.yaml
    
  6. If you have multiple pods setup do this from step 4 for each of them. You can also have multiple definitions in a line using --- as delimiter
answered Sep 18, 2018 by ajs3033
• 7,280 points

Related Questions In Kubernetes

+4 votes
4 answers

local docker image on minikube

I know this is an old question ...READ MORE

answered Feb 1 in Kubernetes by anonymous
13,641 views
0 votes
1 answer

image can't be pulled error when I try to pull a docker image - kubernetes

I think the image is being pulled ...READ MORE

answered Sep 4, 2018 in Kubernetes by Kalgi
• 51,890 points
1,749 views
0 votes
2 answers
0 votes
1 answer

Running Kubernetes on Mac

This error occurs becaouse you have to ...READ MORE

answered Aug 28, 2018 in Kubernetes by Kalgi
• 51,890 points
66 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

Using a local image to create a pod in K8s

I'm not sure but you can try ...READ MORE

answered Apr 29, 2019 in Kubernetes by Vishaka
13,793 views
0 votes
1 answer

Forcing ssl for Kubernetes Ingress on GKE

https://github.com/kubernetes/ingress-gce#frontend-https If you want to block http, you ...READ MORE

answered Sep 6, 2018 in Kubernetes by ajs3033
• 7,280 points
2,693 views