如何使用Ansible创建Kubernetes Secret? [英] How can I create a Kubernetes Secret with Ansible?
问题描述
我正在使用Ansible Jmeter Operator进行分布式负载测试,并且在创建kubernetes Secret时遇到了麻烦.我修改过的运算符是 https://github.com/kubernauts/jmeter-operator 我要添加的其他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 modified is https://github.com/kubernauts/jmeter-operator and the additional yaml I'm adding is as follows:
k8s:
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: azure-storage-account-infxluxdb-secret
namespace: '{{ meta.namespace }}'
stringData:
azurestorageaccountname: 'xxxxxxx'
azurestorageaccountkey: 'xxxxxxxxxxx'
yaml定义有问题吗?我正在修改角色的role/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.
如果需要更多信息,请说,这是我第一次接触k8s!
If there is any more information required please say, this is my first dive into k8s!
推荐答案
这是我的示例,对我有用,希望对您有所帮助.
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屋!