From 37a715c680c118eab21b4a2613cd18acab31fbf0 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Tue, 31 Mar 2020 15:57:50 -0400 Subject: [PATCH] use memcached unix domain socket rather than tcp --- .../roles/image_build/files/launch_awx.sh | 1 - .../templates/launch_awx_task.sh.j2 | 1 - .../kubernetes/templates/configmap.yml.j2 | 2 +- .../kubernetes/templates/deployment.yml.j2 | 18 ++++++++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/installer/roles/image_build/files/launch_awx.sh b/installer/roles/image_build/files/launch_awx.sh index 59d310276d..7dde8192a1 100755 --- a/installer/roles/image_build/files/launch_awx.sh +++ b/installer/roles/image_build/files/launch_awx.sh @@ -8,7 +8,6 @@ fi source /etc/tower/conf.d/environment.sh ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$DATABASE_HOST port=$DATABASE_PORT" all -ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$MEMCACHED_HOST port=$MEMCACHED_PORT" all ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT" all awx-manage collectstatic --noinput --clear diff --git a/installer/roles/image_build/templates/launch_awx_task.sh.j2 b/installer/roles/image_build/templates/launch_awx_task.sh.j2 index c9471a89d9..2e74dab678 100755 --- a/installer/roles/image_build/templates/launch_awx_task.sh.j2 +++ b/installer/roles/image_build/templates/launch_awx_task.sh.j2 @@ -8,7 +8,6 @@ fi source /etc/tower/conf.d/environment.sh ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$DATABASE_HOST port=$DATABASE_PORT" all -ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m wait_for -a "host=$MEMCACHED_HOST port=$MEMCACHED_PORT" all ANSIBLE_REMOTE_TEMP=/tmp ANSIBLE_LOCAL_TEMP=/tmp ansible -i "127.0.0.1," -c local -v -m postgresql_db --become-user $DATABASE_USER -a "name=$DATABASE_NAME owner=$DATABASE_USER login_user=$DATABASE_USER login_host=$DATABASE_HOST login_password=$DATABASE_PASSWORD port=$DATABASE_PORT" all if [ -z "$AWX_SKIP_MIGRATIONS" ]; then diff --git a/installer/roles/kubernetes/templates/configmap.yml.j2 b/installer/roles/kubernetes/templates/configmap.yml.j2 index 1e705c42d5..3555187f60 100644 --- a/installer/roles/kubernetes/templates/configmap.yml.j2 +++ b/installer/roles/kubernetes/templates/configmap.yml.j2 @@ -195,7 +195,7 @@ data: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': '{}:{}'.format("localhost", "11211") + 'LOCATION': 'unix:/var/run/memcached/memcached.sock' }, 'ephemeral': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', diff --git a/installer/roles/kubernetes/templates/deployment.yml.j2 b/installer/roles/kubernetes/templates/deployment.yml.j2 index ab2731274e..96d9906433 100644 --- a/installer/roles/kubernetes/templates/deployment.yml.j2 +++ b/installer/roles/kubernetes/templates/deployment.yml.j2 @@ -150,6 +150,9 @@ spec: - name: {{ kubernetes_deployment_name }}-redis-socket mountPath: "/var/run/redis" + - name: {{ kubernetes_deployment_name }}-memcached-socket + mountPath: "/var/run/memcached" + resources: requests: memory: "{{ web_mem_request }}Gi" @@ -216,6 +219,9 @@ spec: - name: {{ kubernetes_deployment_name }}-redis-socket mountPath: "/var/run/redis" + + - name: {{ kubernetes_deployment_name }}-memcached-socket + mountPath: "/var/run/memcached" env: - name: AWX_SKIP_MIGRATIONS value: "1" @@ -272,6 +278,15 @@ spec: - name: {{ kubernetes_deployment_name }}-memcached image: "{{ kubernetes_memcached_image }}:{{ kubernetes_memcached_version }}" imagePullPolicy: Always + command: + - 'memcached' + - '-s' + - '/var/run/memcached/memcached.sock' + - '-a' + - '0666' + volumeMounts: + - name: {{ kubernetes_deployment_name }}-memcached-socket + mountPath: "/var/run/memcached" resources: requests: memory: "{{ memcached_mem_request }}Gi" @@ -385,6 +400,9 @@ spec: - name: {{ kubernetes_deployment_name }}-redis-socket emptyDir: {} + - name: {{ kubernetes_deployment_name }}-memcached-socket + emptyDir: {} + --- apiVersion: v1 kind: Service