Docker image to be reread by kubernetes google cloud

3/17/2019

as I am green to that subject, could you pls. help.

I deploy docker image to gcloud kubernetes.

What to do to make the cluster reread the docker image when a new one would appear?

My code is:

sudo docker build -t gcr.io/${PROJECT_ID}/sf:$ENV .
sudo docker push gcr.io/${PROJECT_ID}/sf:$ENV
sudo gcloud container clusters create sf:$ENV --num-nodes=3
sudo kubectl run sfmill-web$ENV --image=gcr.io/${PROJECT_ID}/sf:$ENV --port 8088
sudo kubectl expose deployment sfmill-web$ENV --type=LoadBalancer --port 8088 --target-port 8088
-- Steff80
cloud
docker
gcloud
image
kubernetes

1 Answer

3/17/2019
kubectl set image deployment/sfmill-web$ENV sf=sf:$ENV

I encourage you to explore use Kubernetes configuration files to define resources.

You can explore the YAML for your deployment with:

kubectl get deployment/sfmill-web$ENV --output=yaml > ${PWD}/sfmill-web$ENV.yaml

You could then tweak the value of the image property and then reapply this to your cluster using:

kubectl apply --filename=${PWD}/sfmill-web$ENV.yaml

The main benefit to the configuration file approach is that you're effectively creating code to manage your infrastructure and, each time you change your code, you could check it into source control thereby knowing what you did at each stage.

Using kubectl is great but it makes it more challenging to recreate the cluster from scratch.... Which kubectl command did I perform next? Yes, you could (bash) script all your kubectl commands too which would help but configuration files remain the ideal solution.

HTH

-- DazWilkin
Source: StackOverflow