How Do You Create Kubernetes Pods with a .YAML File That Use a Docker Image from a Google Container Registry Instead of Docker Hub?

Problem scenario
You have a .yaml configuration file that works with the kubectl command to create a deployment.  You want to change the source image from the to a Google container source.  How do you configure the .yaml file to obtain the image from a Google container registry instead of Docker Hub?

Your .yaml file has these four lines (among other lines):

      - image: mysql
        name: mysql

You have to identify the URL from first.  Once you have that, substitute the "mysql" on the "- image:" stanza to this new URL.  Here is how the .yaml file's four lines would look:

      - image:
        name: mysql

For Future Reference
Assuming the .yaml file was complete and named contint.yaml, you could now create a Cluster with a command like this:

kubectl create -f contint.yaml

To delete the cluster created with such a file, just use a command like this:

kubectl delete -f contint.yaml

Leave a comment

Your email address will not be published. Required fields are marked *