Ansible task to create service object using inline definition

0 votes
Can you help me write an Ansible task to create a service object from an inline definition? Thank you
Jun 11, 2019 in Ansible by Travis
598 views

1 answer to this question.

0 votes

You can use the k8s module for this purpose. It helps manage all k8s objects. Have a look at this example:

- name: Create service object from an inline definition
  k8s:
    state: present
    definition:
      apiVersion: v1
      kind: Service
      metadata:
        name: webpage
        namespace: testing
        labels:
          app: galaxy
          service: webpage
      spec:
        selector:
          app: galaxy
          service: webpage
        ports:
        - protocol: TCP
          targetPort: 8000
          name: port-8000-tcp
          port: 8000
answered Jun 11, 2019 by Tanya

Related Questions In Ansible

0 votes
1 answer

How to create ECS service on VPC network using Ansible Playbook?

Hi@akhtar, An Amazon ECS service enables you to run and ...READ MORE

answered Dec 4, 2020 in Ansible by MD
• 95,440 points
700 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
955 views
0 votes
1 answer
+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
3,503 views
+2 votes
1 answer
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
742 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
7,423 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