【发布时间】:2021-09-02 01:07:45
【问题描述】:
编写一个 Ansible 剧本,我们从 GIT 存储库中提取项目,然后将所有提取的 yaml 应用到 Kubernetes 集群。
我只看到一个将单个 yaml 文件应用到 Kubernetes 集群的示例,而不是同时应用多个。例如:
- name: Apply metrics-server manifest to the cluster.
community.kubernetes.k8s:
state: present
src: ~/metrics-server.yaml
有没有办法应用多个 yaml 文件?比如:
- name: Apply Services to the cluster.
community.kubernetes.k8s:
state: present
src: ~/svc-*.yaml
或者:
- name: Apply Ingresses to the cluster.
community.kubernetes.k8s:
state: present
dir: ~/ing/
是否还有另一个我应该研究的 Ansible K8s 模块?
或者我们应该直接在 Ansible 任务中运行 kubectl 命令。例如:
- name: Apply Ingresses to the cluster.
command: kubectl apply -f ~/ing/*.yaml
使用 Ansible 实现这一目标的最佳方法是什么?
【问题讨论】:
标签: kubernetes ansible