---
# Set up sock-shop on top of Kubernetes.
# Dependencies on other roles:
# - kubernetes

- name: create sock-shop namespace in k8s
  command: kubectl --kubeconfig /etc/kubernetes/admin.conf create namespace sock-shop

- name: create sock-shop in k8s
  command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -n sock-shop -f "https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml?raw=true"

- name: describe front-end service
  command: kubectl --kubeconfig /etc/kubernetes/admin.conf describe svc front-end -n sock-shop
  changed_when: false
  register: kubectl_describe_svc_frontend
  tags:
    - output

- name: print outpout of `kubectl describe svc front-end -n sock-shop`
  debug: msg="{{ kubectl_describe_svc_frontend.stdout_lines }}"
  tags:
    - output

- name: list sock-shop k8s' pods
  command: kubectl --kubeconfig /etc/kubernetes/admin.conf get pods -n sock-shop
  changed_when: false
  register: kubectl_get_pods
  tags:
    - output

- name: print outpout of `kubectl get pods -n sock-shop`
  debug: msg="{{ kubectl_get_pods.stdout_lines }}"
  tags:
    - output
