DEV Community

Cover image for Install AWX v21.0.0 in Kubernetes with AWX-operator
Damrongsak Reetanon
Damrongsak Reetanon

Posted on

8 3

Install AWX v21.0.0 in Kubernetes with AWX-operator

ผมมักจะ update ความเป็นมาเป็นไปของ AWX อย่างน้อย ๆ ก็สักปีละครับ หยิบมาดูว่ามีอะไรใหม่ ๆ ไหม แต่ส่วนใหญ่ผมเรียนรู้การใช้งาน AWX อยู่ในรูปแบบ container แบบเครื่องเดียวมาตลอด ปีนี้ลองเปลี่ยนใหม่ หยิบมาลงบน K8s ซะหน่อย
ตอนแรกก็คิดว่าจะใช้เวลาหลายวัน คงลองผิดลองถูกติดตั้งเสร็จ ปรากฎว่า ไม่ยากอย่างที่คิดนะ แปร๊บบบบบบเดียวก็ได้ใช้แล้ว เสียเวลาตรงที่ node เรามี memory ไม่พอ ติดตั้งรอบแรกเสร็จก็เลยยังใช้ไม่ได้ มาดูครับ ไม่ยากเลย

ข้อมูลเบื้องต้น

  • Kubernetes 1.23.6
  • node แต่ละ node มีหน่วยความจำ 8 GB (ครั้งแรกทดลองที่ 2 GB ไม่สามารถทำงานได้)
  • awx-operator 0.20.2
  • ใช้ Longhorn เป็น Storageฃ
  • เครื่องที่ใช้ในการติดตั้งต้องมีข้อมูล kubeconfig เรียบร้อยแล้ว
  • เครืื่องที่ใช้ในการติดตั้งมี kubectl ให้พร้อมใช้งาน
  • เครื่องที่ใช้ในการติดตั้งมีระบบปฏิบัติการเป็น macOS version 12.3.1

  • ติดตั้ง kustomize ที่เครื่อง

❯ brew install kustomize
==> Downloading https://ghcr.io/v2/homebrew/core/kustomize/manifests/4.5.4
Already downloaded: /Users/drs/Library/Caches/Homebrew/downloads/4b93fd6dc9174be6d2593f4c63e94d5debc6efcc98907e2397538940cd1f31f7--kustomize-4.5.4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/kustomize/blobs/sha256:1535062dcc42e6776f9506e12e572e19a5c18017543ece5be92e7c770b53490a
Already downloaded: /Users/drs/Library/Caches/Homebrew/downloads/ee6acdadbe5f876b826fd4191717fd9f71c9d35a6ef8a6c360d9f70927625868--kustomize--4.5.4.monterey.bottle.tar.gz
==> Pouring kustomize--4.5.4.monterey.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/kustomize/4.5.4: 8 files, 13.3MB
==> Running `brew cleanup kustomize`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Enter fullscreen mode Exit fullscreen mode
  • สร้าง kustomization.yaml
cat >> kustomization.yaml <<EOF
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - github.com/ansible/awx-operator/config/default?ref=0.20.2
images:
  - name: quay.io/ansible/awx-operator
    newTag: 0.20.2
namespace: awx

EOF
Enter fullscreen mode Exit fullscreen mode
  • เรียกใช้งาน kustomize เพื่อติดตัั้งส่วนประกอบต่าง ๆ ของ awx-operator
❯ kustomize build . | kubectl apply -f -
namespace/awx created
customresourcedefinition.apiextensions.k8s.io/awxbackups.awx.ansible.com created
customresourcedefinition.apiextensions.k8s.io/awxrestores.awx.ansible.com created
customresourcedefinition.apiextensions.k8s.io/awxs.awx.ansible.com created
serviceaccount/awx-operator-controller-manager created
role.rbac.authorization.k8s.io/awx-operator-awx-manager-role created
role.rbac.authorization.k8s.io/awx-operator-leader-election-role created
clusterrole.rbac.authorization.k8s.io/awx-operator-metrics-reader created
clusterrole.rbac.authorization.k8s.io/awx-operator-proxy-role created
rolebinding.rbac.authorization.k8s.io/awx-operator-awx-manager-rolebinding created
rolebinding.rbac.authorization.k8s.io/awx-operator-leader-election-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/awx-operator-proxy-rolebinding created
configmap/awx-operator-awx-manager-config created
service/awx-operator-controller-manager-metrics-service created
deployment.apps/awx-operator-controller-manager created
Enter fullscreen mode Exit fullscreen mode
  • ตรวจสอบสถานะของ awx-operator-controller-manager
❯ kubectl get pods -n awx
NAME                                               READY   STATUS    RESTARTS   AGE
awx-operator-controller-manager-64976659fc-2c9px   2/2     Running   0          61s
Enter fullscreen mode Exit fullscreen mode
  • สร้าง Kubernetes Object ชนิด AWX (ซึ่ง ​CRD นี้ถูกติดตั้งในขั้นตอนที่ 3)
cat >> awx-demo.yaml << EOF
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx-demo
spec:
  service_type: nodeport
EOF
Enter fullscreen mode Exit fullscreen mode

หากต้องการดูคุณสมบัติเพิ่มเติน สามารถดูได้ที่


kubectl explain awx --recursive=true

  • แก้ไข kustomization.yaml โดยเพิ่มบรรทัด - awx-demo.yaml ในส่วนของ resources
cat >> kustomization.yaml <<EOF
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - github.com/ansible/awx-operator/config/default?ref=0.20.2
  - awx-demo.yaml
images:
  - name: quay.io/ansible/awx-operator
    newTag: 0.20.2
namespace: awx

EOF
Enter fullscreen mode Exit fullscreen mode
  • เรียกใช้งาน kustomize เพื่อติดตัั้งส่วนประกอบต่าง ๆ ของ awx-operator อีกครั้ง
/usr/local/bin/kustomize build . | kubectl apply -f -
namespace/awx unchanged
customresourcedefinition.apiextensions.k8s.io/awxbackups.awx.ansible.com unchanged
customresourcedefinition.apiextensions.k8s.io/awxrestores.awx.ansible.com unchanged
customresourcedefinition.apiextensions.k8s.io/awxs.awx.ansible.com unchanged
serviceaccount/awx-operator-controller-manager unchanged
role.rbac.authorization.k8s.io/awx-operator-awx-manager-role configured
role.rbac.authorization.k8s.io/awx-operator-leader-election-role unchanged
clusterrole.rbac.authorization.k8s.io/awx-operator-metrics-reader unchanged
clusterrole.rbac.authorization.k8s.io/awx-operator-proxy-role unchanged
rolebinding.rbac.authorization.k8s.io/awx-operator-awx-manager-rolebinding unchanged
rolebinding.rbac.authorization.k8s.io/awx-operator-leader-election-rolebinding unchanged
clusterrolebinding.rbac.authorization.k8s.io/awx-operator-proxy-rolebinding unchanged
configmap/awx-operator-awx-manager-config unchanged
service/awx-operator-controller-manager-metrics-service unchanged
deployment.apps/awx-operator-controller-manager unchanged
awx.awx.ansible.com/awx-demo created
Enter fullscreen mode Exit fullscreen mode
  • รอการติดตั้ง AWX และสามารถตรวจสอบสถานะการติดตั้งได้จาก
kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator" -n awx -w
NAME                  READY   STATUS    RESTARTS   AGE
awx-demo-postgres-0   1/1     Running   0          56s
awx-demo-7db56584fb-z5kxc   0/4     Pending   0          0s
awx-demo-7db56584fb-z5kxc   0/4     Pending   0          0s
awx-demo-7db56584fb-z5kxc   0/4     ContainerCreating   0          0s
awx-demo-7db56584fb-z5kxc   4/4     Running             0          5s
Enter fullscreen mode Exit fullscreen mode
  • ตรวจสอบรหัสผ่านสำหรับ user admin
❯ kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}"  -n awx | base64 --decode
e5SlKNCgfoES69IexQTDH97DmKr8YHVM%
Enter fullscreen mode Exit fullscreen mode
  • browse ไปที่ http://<IP of nodeport>:<nodeport>

Image description

  • ก้าวแรกกับ AWX Image description
มูลค่าความสุข

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay