From fc77528c79fdb3f6face017ad5a008cc347981e3 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 26 Sep 2024 23:20:00 +0200 Subject: [PATCH] feat(awx): add example of kustomization --- examples/awx/README.md | 9 +++ examples/awx/instance/.gitignore | 2 + examples/awx/instance/awx.yaml | 73 +++++++++++++++++++++ examples/awx/instance/db.env.example | 5 ++ examples/awx/instance/db.secret.env.example | 2 + examples/awx/instance/kustomization.yaml | 23 +++++++ examples/awx/operator/.gitignore | 1 + examples/awx/operator/kustomization.yaml | 21 ++++++ examples/awx/operator/namespace.yaml | 5 ++ 9 files changed, 141 insertions(+) create mode 100644 examples/awx/README.md create mode 100644 examples/awx/instance/.gitignore create mode 100644 examples/awx/instance/awx.yaml create mode 100644 examples/awx/instance/db.env.example create mode 100644 examples/awx/instance/db.secret.env.example create mode 100644 examples/awx/instance/kustomization.yaml create mode 100644 examples/awx/operator/.gitignore create mode 100644 examples/awx/operator/kustomization.yaml create mode 100644 examples/awx/operator/namespace.yaml diff --git a/examples/awx/README.md b/examples/awx/README.md new file mode 100644 index 0000000..1f18a7e --- /dev/null +++ b/examples/awx/README.md @@ -0,0 +1,9 @@ +# AWX example + +```sh +kubectl kustomize --enable-helm 'operator/' | kubectl apply -f - +kubectl apply -k 'instance/' +kubectl -n 'awx' get secret 'awx-admin-password' -o jsonpath="{.data.password}" | base64 --decode +kubectl get ingress -n 'awx' 'awx-ingress' -o jsonpath='{.status.loadBalancer.ingress[*].hostname}' \ +| xargs -I{} open http://{} +``` diff --git a/examples/awx/instance/.gitignore b/examples/awx/instance/.gitignore new file mode 100644 index 0000000..f62cdd3 --- /dev/null +++ b/examples/awx/instance/.gitignore @@ -0,0 +1,2 @@ +/db.env +/db.secret.env diff --git a/examples/awx/instance/awx.yaml b/examples/awx/instance/awx.yaml new file mode 100644 index 0000000..890a664 --- /dev/null +++ b/examples/awx/instance/awx.yaml @@ -0,0 +1,73 @@ +--- + +# See the installer role's defaults at +# and any page under the +# 'Advanced configuration' section in the operator's documentation at +# for details. + +apiVersion: awx.ansible.com/v1beta1 +kind: AWX +metadata: + name: awx +spec: + admin_email: admin@company.com + postgres_configuration_secret: awx-postgres-configuration + node_selector: + # force amd64 - arm images seem to be not ready + | + kubernetes.io/arch: amd64 + service_type: NodePort + ingress_type: ingress + task_tolerations: | + - key: "dedicatedTo" + operator: "Equal" + value: "awx" + effect: "NoSchedule" + - key: "dedicatedTo" + operator: "Equal" + value: "awx-task" + effect: "NoSchedule" + task_affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: dedicatedTo + operator: In + values: + - awx + - awx-task + task_resource_requirements: + # Averages at about 17-45m vCPU and 850Mi RAM when chilling unused + # Averages at about 503m vCPU and 1094Mi RAM with one task starting + # Went as up as 1778m and 1037Mi RAM during initialization + requests: + cpu: 30m + memory: 800Mi + web_tolerations: | + - key: "dedicatedTo" + operator: "Equal" + value: "awx" + effect: "NoSchedule" + - key: "dedicatedTo" + operator: "Equal" + value: "awx-web" + effect: "NoSchedule" + web_affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: dedicatedTo + operator: In + values: + - awx + - awx-web + web_resource_requirements: + # Averages at about 18-150m vCPU and 1250Mi RAM when chilling unused + # Averages at about 750m vCPU and 1280Mi RAM with one user browsing + # Went as up as 1883m and 1328Mi RAM during initialization + requests: + cpu: 50m + memory: 1.25Gi + no_log: true diff --git a/examples/awx/instance/db.env.example b/examples/awx/instance/db.env.example new file mode 100644 index 0000000..b426996 --- /dev/null +++ b/examples/awx/instance/db.env.example @@ -0,0 +1,5 @@ +host=awx.db.company.com +port=5432 +database=awx +sslmode=prefer +type=unmanaged diff --git a/examples/awx/instance/db.secret.env.example b/examples/awx/instance/db.secret.env.example new file mode 100644 index 0000000..92bda8d --- /dev/null +++ b/examples/awx/instance/db.secret.env.example @@ -0,0 +1,2 @@ +username=awxmaster +password=Evaluate9-Confiding5-Emphasize6 diff --git a/examples/awx/instance/kustomization.yaml b/examples/awx/instance/kustomization.yaml new file mode 100644 index 0000000..59bc940 --- /dev/null +++ b/examples/awx/instance/kustomization.yaml @@ -0,0 +1,23 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: awx +labels: + - includeSelectors: true + pairs: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/part-of: awx + +generatorOptions: + disableNameSuffixHash: true + +secretGenerator: + - name: awx-postgres-configuration + envs: + - db.env + - db.secret.env + +resources: + - awx.yaml diff --git a/examples/awx/operator/.gitignore b/examples/awx/operator/.gitignore new file mode 100644 index 0000000..721e9b3 --- /dev/null +++ b/examples/awx/operator/.gitignore @@ -0,0 +1 @@ +/charts/ diff --git a/examples/awx/operator/kustomization.yaml b/examples/awx/operator/kustomization.yaml new file mode 100644 index 0000000..9ee8036 --- /dev/null +++ b/examples/awx/operator/kustomization.yaml @@ -0,0 +1,21 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: awx +labels: + - includeSelectors: true + pairs: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/part-of: awx + +resources: + - namespace.yaml +helmCharts: + - name: awx-operator + repo: https://ansible.github.io/awx-operator/ + version: 2.19.1 + releaseName: awx-operator + includeCRDs: true # Important that it is true; *not* namespaced, watch out upon removal + # FIXME: set resources -> requires 10m+32Mi, leave limitless (peaked at 1880m+799Mi during init) diff --git a/examples/awx/operator/namespace.yaml b/examples/awx/operator/namespace.yaml new file mode 100644 index 0000000..e24dd13 --- /dev/null +++ b/examples/awx/operator/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: awx