|
1 | 1 | - hosts: "{{ env }}" |
2 | 2 | become: yes |
3 | 3 | tasks: |
4 | | - - name: remove any previous app services |
| 4 | + - name: Deploying Application pods... |
5 | 5 | shell: | |
6 | | - if [ `kubectl get deploy | grep -v NAME | awk '{print $1}' | grep sampleapp | wc -l` -gt 0 ]; then |
7 | | - kubectl delete deploy `kubectl get deploy | grep -v NAME | awk '{print $1}' | grep sampleapp` |
| 6 | + if [ `kubectl get deployment | grep -v NAME | awk '{print $1}' | grep sampleapp | wc -l` -gt 0 ]; then |
| 7 | + echo "deleteing previous application deployment" |
| 8 | + kubectl delete deployment `kubectl get deployment | grep -v NAME | awk '{print $1}' | grep sampleapp` |
| 9 | + echo "creating new application deployment" |
| 10 | + kubectl create deployment sampleapp --image=lerndevops/samplejavaapp:{{ build }} |
8 | 11 | else |
9 | | - echo "No app deployments found" |
| 12 | + echo "Deploying Sampleapp Application" |
| 13 | + kubectl create deployment sampleapp --image=lerndevops/samplejavaapp:{{ build }} |
10 | 14 | fi |
| 15 | + - name: deploying service |
| 16 | + shell: | |
11 | 17 | if [ `kubectl get svc | grep sampleapp | awk '{print $1}' | wc -l` -gt 0 ]; then |
12 | 18 | echo "app service found, No actions taken" |
13 | 19 | #kubectl delete svc `kubectl get svc | grep sampleapp | awk '{print $1}'` |
14 | 20 | else |
15 | | - echo "No app service found it will be created" |
| 21 | + echo "Creating App Services" |
| 22 | + kubectl expose deployment sampleapp --name sampleapp --type NodePort --port 80 --target-port 8080 |
16 | 23 | fi |
17 | | - - name: deploy app |
18 | | - shell: kubectl create deployment sampleapp --image=lerndevops/samplejavaapp:{{ build }} |
19 | 24 | - name: increase replicas |
20 | 25 | shell: kubectl scale deploy sampleapp --replicas=2 |
21 | | - - name: deploy service |
22 | | - shell: kubectl expose deployment sampleapp --name sampleapp --type NodePort --port 80 --target-port 8080 |
| 26 | + |
| 27 | + #- name: deploy app |
| 28 | + # shell: kubectl create deployment sampleapp --image=lerndevops/samplejavaapp:{{ build }} |
| 29 | + #- name: deploy service |
| 30 | + # shell: kubectl expose deployment sampleapp --name sampleapp --type NodePort --port 80 --target-port 8080 |
0 commit comments