Skip to content

Create ephemeral environment Docker image for ubuntu/debian base and output k8s manifests #8

Create ephemeral environment Docker image for ubuntu/debian base and output k8s manifests

Create ephemeral environment Docker image for ubuntu/debian base and output k8s manifests #8

Workflow file for this run

name: Create ephemeral environment Docker image
on:
workflow_dispatch:
inputs:
container_name:
description: "Container name"
required: false
default: "app" # container name. APP_NAME is used on k8s labels/selectors.
base_image:
description: "Base image to build from"
required: true
default: "python:3.12-slim"
name:
description: "Name of the environment"
required: false
default: "riley-minikube-python"
packages:
description: "Packages to install on base image"
required: false
cpu:
description: "CPU allocation"
required: true
default: "256m"
memory:
description: "Memory allocation"
required: true
default: "512Mi"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Show selected inputs
run: |
echo "Base image to build: ${{ github.event.inputs.base_image }}"
echo "Environment name: ${{ github.event.inputs.name }}"
echo "Packages to be installed: ${{ github.event.inputs.packages }}"
echo "CPU Requested: ${{ github.event.inputs.cpu }}"
echo "Memory Requested: ${{ github.event.inputs.memory }}"
- name: Export template variables
run: |
cat <<EOF >> $GITHUB_ENV
DEPLOYMENT_NAME=${{ github.event.inputs.name }}
SERVICE_NAME=${{ github.event.inputs.name }}
# APP_NAME=${{ github.event.inputs.name }}
APP_NAME=app-${{ github.actor }}-${{ github.event.inputs.name }}-${{ github.run_number }}
CONTAINER_NAME=${{ github.event.inputs.container_name }}
IMAGE=${{ github.event.inputs.base_image }}
CPU_REQUEST=${{ github.event.inputs.cpu }}
MEMORY_REQUEST=${{ github.event.inputs.memory }}
CPU_LIMIT=${{ github.event.inputs.cpu }}
MEMORY_LIMIT=${{ github.event.inputs.memory }}
SERVICE_PORT=80
TARGET_PORT=8080
EOF
- name: Render Kubernetes manifests
run: |
envsubst < ops/deploy.tpl.yaml > ops/deploy.yaml
envsubst < ops/service.tpl.yaml > ops/service.yaml
- name: Validate Kubernetes for Deployment # Of course, this would not be a dry run if I had a real cluster to deploy to.
uses: docker://ghcr.io/yannh/kubeconform:latest
with:
args: "-strict -ignore-missing-schemas ops/deploy.yaml ops/service.yaml"