Deploy Interview App #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | |