Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,53 @@ jobs:
kops get cluster einalien.k8s.local \
--state="$KOPS_STATE_STORE" > /dev/null
echo "kOps state store access verified."
echo "kOps state store access verified."
# Generate short-lived Kubernetes credentials.
- name: Generate Kubernetes kubeconfig
shell: bash
env:
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.KOPS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.KOPS_APPLICATION_CREDENTIAL_SECRET }}
run: |
set -euo pipefail
KUBECONFIG_FILE="$RUNNER_TEMP/assignment2-kubeconfig"
umask 077
kops export kubeconfig einalien.k8s.local \
--admin=1h \
--state="$KOPS_STATE_STORE" \
--kubeconfig="$KUBECONFIG_FILE"
test -s "$KUBECONFIG_FILE"
chmod 600 "$KUBECONFIG_FILE"
# Verify that the generated configuration contains a cluster context.
KUBECONFIG="$KUBECONFIG_FILE" kubectl config current-context
# Make the kubeconfig available to subsequent steps.
echo "KUBECONFIG=$KUBECONFIG_FILE" >> "$GITHUB_ENV"
echo "KUBE_CONFIG_PATH=$KUBECONFIG_FILE" >> "$GITHUB_ENV"
# Confirm that the runner can communicate with Kubernetes.
- name: Verify Kubernetes state access
shell: bash
run: |
set -euo pipefail
kubectl --request-timeout=15s get --raw=/readyz
kubectl --request-timeout=15s get namespace iac
# Check the permissions required by the state backend.
kubectl auth can-i get secrets -n iac --quiet
kubectl auth can-i create leases.coordination.k8s.io -n iac --quiet
echo "Kubernetes state backend access verified."
# Remove temporary credentials even when verification fails.
- name: Clean up Kubernetes credentials
if: always()
shell: bash
run: |
rm -f "$RUNNER_TEMP/assignment2-kubeconfig"