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 693 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,850 points
189 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,620 points
172 views
0 votes
1 answer

Create a directory at a specific path using ansible

To create a directory using Ansible, you ...READ MORE

answered Jan 9, 2019 in Ansible by Jason
119 views
0 votes
1 answer

Create directories and download files in Ansible using Ansible playbook

Hey @Yash,  you could either use file module ...READ MORE

answered Jan 24, 2019 in Ansible by Cerdin
1,558 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
5,628 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 11, 2019 in Kubernetes by Kalgi
• 51,830 points

reshown Apr 12, 2019 by Kalgi 1,533 views
0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
123 views
0 votes
2 answers

How to create MySQL tables using Ansible?

--- - hosts: dbserver   tasks:    - name: create a table ...READ MORE

answered Mar 19, 2019 in Ansible by Ankit Tyagi
2,230 views