# Create custom images, push them to google cloud registry and deploy awx on kubernetes

**URL:** <https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812>\
**Category:** AWX Project\
**Tags:** kubernetes, awx\
**Created:** [March 3, 2019, 2:38am UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812 "2019-03-03T02:38:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 3, 2019, 2:38am UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/1 "2019-03-03T02:38:21Z")

</div>

Hi,

I want to create a custom version of awx\_task (with dnspython and openshift installed) and push this image to gcr.

I have modified requirements/requirements\_ansible.txt to add dnspython and openshift. The build is successful and I have awx\_task modified as I want.

[james@e6230 awx-3.0.0]$ sudo docker images  
REPOSITORY TAG IMAGE ID CREATED SIZE  
awx\_task 3.0.0 5b7592c577c3 25 minutes ago 1.05 GB  
awx\_task latest 5b7592c577c3 25 minutes ago 1.05 GB  
awx\_web 3.0.0 c31bc1361abb 26 minutes ago 1.02 GB  
awx\_web latest c31bc1361abb 26 minutes ago 1.02 GB

As far as I read I can’t see how to achieve my goal.

The images are local and I don’t know how to push them on gcr and how to deploy awx with this images.

If someone can help me … it will be appreciated.

James

---

<div class="post-metadata">

**Author:** ![David\_Maple](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@David\_Maple](https://forum.ansible.com/u/David_Maple)\
**Post date:** [March 3, 2019, 5:09am UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/2 "2019-03-03T05:09:38Z")

</div>

That question is really about deploying images to GCP, which seems outside the scope of this list. You can export a docker image to a tar file. Or tag it and push to a docker registry where you might be able to pull it within GCP.

Dave

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 3, 2019, 12:50pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/3 "2019-03-03T12:50:58Z")

</div>

Hi David,  
Thanks for you answer. I know how to deploy image from private gcr to gke (on gcp). My question was about the inventory file.

I have set all the mandatory variables to be able to push and pull images from gcr but maybe I am missing something.

From the command line I can push and pull images to gcr.

inventory file looks like :

---

<div class="post-metadata">

**Author:** ![David\_Maple](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@David\_Maple](https://forum.ansible.com/u/David_Maple)\
**Post date:** [March 3, 2019, 3:55pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/4 "2019-03-03T15:55:25Z")

</div>

I see what you’re trying to do. Sorry, I didn’t get that from your initial question.

Are you setting registry authentication variables? Looking at the installer/roles/image\_push/tasks/main.yml file, the first docker\_login task oly happens when the docker\_registry and docker\_registry\_password variables are defined. When you run the install.yml playbook, does it perform the tasks in the image\_push role, or does it skip them?

Here’s what I have working. I’m using OpenShift Origin, but it is still just a docker registry.

docker\_registry: docker-registry.default.svc:5000  
docker\_registry\_repository: awx  
docker\_registry\_username: unused  
docker\_registry\_password: “{{ token }}”

I’m using an auth token instead of a username and password. I set the token variable when I run:

> ansible-playbook install.yml -e token=$(oc whoami -t)

Your kubectl probably has a similar (or exactly the same) command.

Hope that helps,

Dave

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 3, 2019, 7:15pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/5 "2019-03-03T19:15:37Z")

</div>

I have follow your advice and find out how I can get a token to access gcr.

[https://cloud.google.com/container-registry/docs/advanced-authentication#access\_token](https://cloud.google.com/container-registry/docs/advanced-authentication#access_token)

the inventory file looks like :

docker\_registry=[gcr.io](http://gcr.io)  
docker\_registry\_repository=mycontext-123456  
docker\_registry\_username=oauth2accesstoken

and the command line is :

---

<div class="post-metadata">

**Author:** ![David\_Maple](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@David\_Maple](https://forum.ansible.com/u/David_Maple)\
**Post date:** [March 3, 2019, 9:25pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/6 "2019-03-03T21:25:07Z")

</div>

It does look like it’s working. You might try adding -vvv to the ansible-playbook command to see if it gives you anything useful.

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 3, 2019, 10:19pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/7 "2019-03-03T22:19:20Z")

</div>

some observations :

1. the awx containers are built with the new modules (dnspython and openshift) and the images are on my laptop

> **(attachments)**
>
> [awx-k8s.txt](https://forum.ansible.com/uploads/short-url/ZzKNtlR8effBlmZ1OWbJBQr8B6.txt) (200 KB)

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 5, 2019, 2:40am UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/8 "2019-03-05T02:40:10Z")

</div>

I have found something very strange. To be able to create custom images, push them to GCR and run AWX from this images, I have to comment

#kubernetes\_task\_image: “{{ tower\_package\_name | default(‘ansible/awx\_task’) }}”  
#kubernetes\_web\_image: “{{ tower\_package\_name | default(‘ansible/awx\_web’) }}”

```auto
in **installer/roles/kubernetes/defaults/main.yml**. If kubernetes_task_image and kubernetes_web_image are not commented, it's impossible to use the build images.

Now I have another question. Once AWX is deployed with the custom images and the custom modules (dnspython and openshift) is installed, I still cannot run my playbook. I've got this message :

Using /etc/ansible/ansible.cfg as config file
/tmp/awx_13_xxfdcqtw/tmpwqww2_5w did not meet host_list requirements, check plugin documentation if this is unexpected

PLAY [localhost] ***************************************************************

TASK [deploy-on-k8s : debug] ***************************************************
ok: [localhost] => {
"msg": "1.17"
}

TASK [deploy-on-k8s : Fetch all certificates in a Namespace] *******************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "This module requires the OpenShift Python client. Try `pip install openshift`"}

PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1

Any help will be welcome.
```

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 6, 2019, 10:19pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/9 "2019-03-06T22:19:50Z")

</div>

I had to set :

**ansible\_connection: local**  
**ansible\_python\_interpreter: “/var/lib/awx/venv/ansible/bin/python2”**

in my inventory .

After that everything works as expected.

---

<div class="post-metadata">

**Author:** ![James\_James](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@James\_James](https://forum.ansible.com/u/James_James)\
**Post date:** [March 6, 2019, 10:21pm UTC](https://forum.ansible.com/t/create-custom-images-push-them-to-google-cloud-registry-and-deploy-awx-on-kubernetes/29812/10 "2019-03-06T22:21:01Z")

</div>


