Create k8s namespace using ansible

0 votes
I'm trying to write an Ansible task to create k8s namespace. can you help me out? Thanks
Jun 11, 2019 in Ansible by Travis

edited Jun 11, 2019 7,108 views

2 answers to this question.

0 votes

Hey @Travus, you can use the k8s module of Ansible which is used to manage k8s objects. Have a look at this example to write a task to create a namespace for k8s:

- name: Create a k8s namespace
  k8s:
    name: Kubernetes
    api_version: v1
    kind: Namespace
    state: present
answered Jun 11, 2019 by Faiza
0 votes

You can also create a kubernetes namespace using the Kubernetes module of Ansible.

- name: Create a kubernetes namespace
  kubernetes:
    api_endpoint: specify-endpoint #specify the endpoint
    url_username: admin  #username
    url_password: samplepass  #password for your username
    file_reference: /path-create-namespace.yaml  #the location where you wish to create the namespace
    state: present
answered Jun 11, 2019 by Nasser

edited Jun 11, 2019

Related Questions In Ansible

0 votes
1 answer

How can I create a new user using ansible ploybook?

You're switching from the root user. Root ...READ MORE

answered Mar 29, 2018 in Ansible by DareDev
• 6,890 points
747 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,680 points
1,020 views