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 • 10,357 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
• 2,064 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
• 2,332 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
• 2,141 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
• 7,380 views
+1 vote
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
• 20,338 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
• 9,050 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
• 2,259 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
• 10,121 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP