如何使用 Ansible 创建 Kubernetes Secret? [英] How can I create a Kubernetes Secret with Ansible?
本文介绍了如何使用 Ansible 创建 Kubernetes Secret?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Ansible JMeter Operator 进行分布式负载测试,但在创建 Kubernetes 密钥时遇到问题.我正在修改的操作符是 JMeter 一个,我添加的附加 YAML 是下面:
I'm using an Ansible JMeter Operator to do distributed load testing and am having trouble with creating a Kubernetes secret. The operator I'm modifying is the JMeter one and the additional YAML I'm adding is as below:
- name: InfluxDB Storage Secret
k8s:
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: azure-storage-account-infxluxdb-secret
namespace: '{{ meta.namespace }}'
stringData:
azurestorageaccountname: 'xxxxxxx'
azurestorageaccountkey: 'xxxxxxxxxxx'
YAML 定义有什么问题吗?我正在修改角色的 roles/jmeter/tasks/main.yaml 以将其添加到我的特定命名空间中.
Is there anything wrong with the YAML definition? I'm modifying the roles/jmeter/tasks/main.yaml of the role to add it into my specific namespace.
推荐答案
这是我的例子,对我有用,希望对我有帮助.
Here is my example, that works for me, hope it help.
- name: CREATE MONGOSECRETS SECRET
k8s:
state: present
definition:
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: "{{ secret_name }}"
namespace: "{{ project_name | lower }}"
data:
config_data.json: "{{ lookup('template', mongo_conn_templates_path + '/config_data.json' ) | tojson | b64encode }}"
这篇关于如何使用 Ansible 创建 Kubernetes Secret?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文