-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathkubernetes-troubleshooting-scenarios.yml
More file actions
103 lines (92 loc) · 2.6 KB
/
kubernetes-troubleshooting-scenarios.yml
File metadata and controls
103 lines (92 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Deploy Interview App
on:
workflow_dispatch:
inputs:
namespace:
description: 'Namespace to deploy to'
required: false
default: 'troubleshooting-scenarios'
env:
IMAGE_NAME: becloudready/k8s-troubleshooting-scenarios
IMAGE_TAG: 7.0.0
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Kubernetes tools
uses: azure/setup-kubectl@v3
with:
version: 'latest'
- name: Configure Kubernetes cluster
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
kubectl version --client
- name: Create namespace if needed
run: |
kubectl create namespace ${{ inputs.namespace }} --dry-run=client -o yaml | kubectl apply -f -
- name: Apply ConfigMap
run: |
cat <<EOF | kubectl apply -n ${{ inputs.namespace }} -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config.yml: |
database:
host: db-service
port: 5432
logging:
level: debug
EOF
- name: Deploy Interview App
run: |
cat <<EOF | kubectl apply -n ${{ inputs.namespace }} -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: interview-app
spec:
replicas: 1
selector:
matchLabels:
app: interview
template:
metadata:
labels:
app: interview
spec:
dnsPolicy: "Default"
dnsConfig:
nameservers:
- "203.0.113.123"
searches:
- google.com
options:
- name: ndots
value: "1"
containers:
- name: main
image: \${{ env.IMAGE_NAME }}:\${{ env.IMAGE_TAG }}
command: ["python3", "/app/troubleshoot_scenarios.py"]
volumeMounts:
- name: config-vol
mountPath: /etc/app
resources:
limits:
memory: "256Mi"
cpu: "500m"
volumes:
- name: config-vol
configMap:
name: app-config
items:
- key: config1.yml
path: config.yaml
EOF
- name: Verify Deployment
run: |
kubectl get pods -n ${{ inputs.namespace }}