使用Ansible Container将容器部署到Kubernetes和OpenShift
1. 部署容器到Kubernetes
Ansible Container工作流十分灵活,对于希望采用Ansible进行远程部署的组织和个人来说,它能很好地支持使用Kubernetes和OpenShift进行部署。下面将介绍如何使用ansible-container deploy命令,把容器部署到Google Cloud Kubernetes集群。
1.1 准备工作
若使用Google Cloud Kubernetes集群,需设置默认访问令牌,以便Ansible Container访问Google Cloud API。可执行以下命令:
ubuntu@node01:$ gcloud auth application-default login Go to the following link in your browser: https://accounts.google.com/o/oauth2/TRUNCATED Enter verification code: XXXXXXXXXXXXXXX Credentials saved to file: [/home/ubuntu/.config/gcloud/application_default_credentials.json]若使用本地Kubernetes环境(如Minikube),可跳过此步骤。