AWX 介绍
AWX 是一个开源社区项目,提供用于管理Ansible 项目的软件。AWX 托管在GitHub 上,并提供基于Web 的用户界面、REST API 和适用于Ansible 的任务引擎。Ansible 是一款开发运营工具,可自动执行预置、配置管理、应用程序部署、内部服务编排、持续交付和许多其他IT 流程。
Github地址:https://github.com/ansible/awx
AWX安装
AWX 17 版本以前可以通过各种发放进行安装,比如通过docker-compose工具直接运行。但18版本以后只能通过AWX operator进行安装。AWX operator可以将AWX自动部署到各种K8S集群中,比如原生版K8S、OpenShift等。
我只是为了测试用,直接选择安装在minikube中。
minikube安装
我直接用mac上的docker desktop自带的功能,运行了一个minikube集群。
安装K8S步骤
将环境切换为刚安装的k8s环境AWX安装
K8S集群有了以后就可以通过AWX Operator进行。AWX Operator的参考文档。
创建一个Operator文件 kustomization.yaml,内容如下
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# Operator版本号可以从这里找到:https://github.com/ansible/awx-operator/releases
- github.com/ansible/awx-operator/config/default?ref=1.1.3
# Set the image tags to match the git version from above
images:
- name: quay.io/ansible/awx-operator
newTag: 1.1.3
# Specify a custom namespace in which to install AWX
namespace: awx
执行命令加载Operator
mervin@MBook-Pro awx-19.3.0 % 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 configured
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 configured
awx.awx.ansible.com/awx-demo created
执行完成后会在K8S中创建一个namespace awx,切换到awx中
kubectl config set-context --current --namespace=awx
接下来,使用下面建议的内容创建一个awx-demo.yaml在同一文件夹中命名的文件。您提供的metadata.name将是生成的 AWX 部署的名称。
然后将此文件引用到 kustomization.yaml 中,内容如下:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/ansible/awx-operator/config/default?ref=1.1.3
- awx-demo.yaml
# Set the image tags to match the git version from above
images:
- name: quay.io/ansible/awx-operator
newTag: 1.1.3
# Specify a custom namespace in which to install AWX
namespace: awx
执行命令更新Operator配置
kustomize build . | kubectl apply -f -
等待Operator创建完所有的资源,然后用命令查看所有资源的状态
mervin@MBook-Pro awx-19.3.0 % kubectl get all
NAME READY STATUS RESTARTS AGE
pod/awx-demo-589886bb5-hdmhh 4/4 Running 4 (52m ago) 25h
pod/awx-demo-postgres-13-0 1/1 Running 2 (52m ago) 2d11h
pod/awx-operator-controller-manager-577f6968b5-zkd22 2/2 Running 8 (52m ago) 2d12h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/awx-demo-postgres-13 ClusterIP None <none> 5432/TCP 2d11h
service/awx-demo-service NodePort 10.98.114.219 <none> 80:30080/TCP 2d11h
service/awx-operator-controller-manager-metrics-service ClusterIP 10.111.206.12 <none> 8443/TCP 2d12h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/awx-demo 1/1 1 1 2d11h
deployment.apps/awx-operator-controller-manager 1/1 1 1 2d12h
NAME DESIRED CURRENT READY AGE
replicaset.apps/awx-demo-589886bb5 1 1 1 2d11h
replicaset.apps/awx-operator-controller-manager-577f6968b5 1 1 1 2d12h
NAME READY AGE
statefulset.apps/awx-demo-postgres-13 1/1 2d11hAWX使用获取AWX管理员密码
默认AWX安装的时候如果没有提供 admin 用户密码则Operator会初始化一个随机密码,可以用命令从secret中获得密码内容:
# kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode ; echo
VzXLHbwqRB8z8pT1kIrC15tQLKBaTKpU登录AWX
通过浏览器登录AWX,默认端口是30080,定义在awx-demo.yaml文件中
领取专属 10元无门槛券
私享最新 技术干货