ansible / ansible-kubernetes-modules

DEPRECATED Ansible role containing pre-release K8s modules
Apache License 2.0
73 stars 39 forks source link

Cannot make a Headless service #24

Open dr-shim opened 6 years ago

dr-shim commented 6 years ago

I was trying to make 'Headless service' with this code

- name: create test service
  k8s_v1_service:
    name: test
    namespace: '{{ namespace }}'
    state: present
    labels:
      app: test
    selector:
      app: test
    spec_cluster_ip: 'None'
    ports:
    - port: 1234
      protocol: TCP

But, it doesn't work. It seems that any of the aliases (cluster_ip: && spec: cluster_ip:) of spec_cluster_ip: doesn't work. Is there anyone who tried to make Headless service using APB?

rahulinux commented 6 years ago

Following is working :

    k8s_v1_service:
      name: my-svc
      namespace:  default
      labels:
        app: my-svc
      spec_cluster_ip: 'None'
      spec_ports:
        - name: my-svc
          port: 9042
          targetPort: 9042
          protocol: TCP
      spec_selector:
        app: my-svc
dr-shim commented 6 years ago

@rahulinux
I just tried your code, but it also doesn't work for me. Are you sure you were able to make Headless service with this code?

dr-shim commented 6 years ago

@rahulinux I expected that the provisioned service has its Cluster IP as 'None', but it has a random IP address. I think the ansible service broker has some kind of a problem in this part, becuase if I made the same service with direct yaml file

( Project name -> Application -> Services -> Add to Project -> Import YAML / JSON)

, it's perfectly working, having its Cluster IP as 'None'.

Here is the direct YAML file which provision the same service.

apiVersion: v1
kind: Service
metadata:
  labels:
    app: cassandra
  name: cassandra
spec:
  clusterIP: None
  ports:
  - port: 9042
  selector:
    app: cassandra