Example Python App for use with the From DevOps to Platform Engineering: Master Backstage & IDPs course created by Ricardo Andre Gonzalez Gomez on Udemy.
You'll need Devbox installed, and the ideal IDE is Visual Studio Code.
% devbox shell
% pip install -r requirements.txt% flask --app app.py --debug run
* Serving Flask app 'app.py'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000Note: You'll need Docker Desktop locally.
% docker build -t python-app:v2 .% docker run -p 8080:5000 python-app:v2Note: You'll need to have a Docker Hub account and to have you local environment set up to authenticare with Docker Hub using an access token.
% docker tag python-app:v2 loickreitmann/python-app:v2
% docker push loickreitmann/python-app:v2Note: You'll need Rancher Desktop running locally.
% kubectl apply -f k8s/deploy.yaml
% kubectl apply -f k8s/service.yaml
% kubectl apply -f k8s/ingresss.yaml% kubectl describe svc python-app
Name: python-app
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=python-app
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.47.207
IPs: 10.43.47.207
Port: <unset> 8080/TCP
TargetPort: 5000/TCP
Endpoints: 10.42.0.239:5000
Session Affinity: None
Internal Traffic Policy: Cluster
Events: <none>% kubectl get ing
NAME CLASS HOSTS ADDRESS PORTS AGE
python-app traefik python-app.local 10.0.0.206 80 5m23s% kubectl delete -f k8s
deployment.apps "python-app" deleted
ingress.networking.k8s.io "python-app" deleted
service "python-app" deletedCreated the charts directory and created our helm app.
% mkdir charts
% cd charts
% helm create python-app% cd charts/python-app
% helm install python-app -n python-app . --create-namespace
NAME: python-app
LAST DEPLOYED: Sun Apr 6 14:04:28 2025
NAMESPACE: python-app
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
http://python-app.local/% helm uninstall python-app -n python-app% helm repo add argo https://argoproj.github.io/argo-helm
"argo" has been added to your repositories
% helm repo ls
NAME URL
argo https://argoproj.github.io/argo-helmFrom the project's root, run the following:
% cd charts/argocd
% helm upgrade --install argocd argo/argo-cd -n argocd --create-namespace -f values-argo.yaml
Release "argocd" does not exist. Installing it now.
NAME: argocd
LAST DEPLOYED: Sun Apr 13 17:11:26 2025
NAMESPACE: argocd
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
In order to access the server UI you have the following options:
1. kubectl port-forward service/argocd-server -n argocd 8080:443
and then open the browser on http://localhost:8080 and accept the certificate
2. enable ingress in the values file `server.ingress.enabled` and either
- Add the annotation for ssl passthrough: https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/#option-1-ssl-passthrough
- Set the `configs.params."server.insecure"` in the values file and terminate SSL at your ingress: https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/#option-2-multiple-ingress-objects-and-hosts
After reaching the UI the first time you can login with username: admin and the random password generated during the installation. You can find the password by running:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
(You should delete the initial secret afterwards as suggested by the Getting Started Guide: https://argo-cd.readthedocs.io/en/stable/getting_started/#4-login-using-the-cli)From the project's root, run the following:
% cd argocd/
% kubectl apply -f argocd-ingress.yamlFrom the project's root, run the following:
% cd argocd/
% kubectl apply -f argocd-grpc-ingress.yamlTo use the argocd CLI, run the login script from within the argocd/ directory. This script exposes the Argo CD API with port forwarding, since this local setup doesn't use TLS.
% sh argocd-local-login.sh
π Starting port-forward to Argo CD server...
β³ Waiting for port 8080 to be available...
Connection to localhost port 8080 [tcp/http-alt] succeeded!
Connection to localhost port 8080 [tcp/http-alt] succeeded!
β
Port-forward established.
π Getting Argo CD admin password...
π Logging in to Argo CD CLI at localhost:8080...
FATA[0003] Failed to establish connection to localhost:8080: EOF
π Killing port-forward (PID 4570)
argocd/argocd-local-login.sh: line 1: kill: (4570) - No such processYou'll now be able to run argocd command in your terminal.
% argocd proj list
NAME DESCRIPTION DESTINATIONS SOURCES CLUSTER-RESOURCE-WHITELIST NAMESPACE-RESOURCE-BLACKLIST SIGNATURE-KEYS ORPHANED-RESOURCES DESTINATION-SERVICE-ACCOUNTS
default *,* * */* <none> <none> disabled <none>% argocd version
argocd: v2.14.7
BuildDate: unknown
GitCommit: v2.14.7
GitTreeState: clean
GitTag: v2.14.7
GoVersion: go1.24.1
Compiler: gc
Platform: darwin/arm64
argocd-server: v2.14.9+38985bd
BuildDate: 2025-04-02T19:31:28Z
GitCommit: 38985bdcd6c3b031fb83757a1fb0c39a55bf6a24
GitTreeState: clean
GoVersion: go1.23.3
Compiler: gc
Platform: linux/arm64
Kustomize Version: v5.4.3 2024-07-19T16:40:33Z
Helm Version: v3.16.3+gcfd0749
Kubectl Version: v0.31.0
Jsonnet Version: v0.20.0% argocd app list
NAME CLUSTER NAMESPACE PROJECT STATUS HEALTH SYNCPOLICY CONDITIONS REPO PATH TARGET
argocd/python-app https://kubernetes.default.svc python-app default Synced Healthy Auto <none> https://github.com/loickreitmann/python-app.git charts/python-app HEADUsing an Actions Runner Controller (ARC) makes it simpler to run self hosted environments on Kubernetes(K8s) cluster.
With ARC you can :
- Deploy self hosted runners on Kubernetes cluster with a simple set of commands.
- Auto scale runners based on demand.
- Setup across GitHub editions including GitHub Enterprise editions and GitHub Enterprise Cloud.
We'll use Helm to prepare the installation.
% helm repo add jetstack https://charts.jetstack.io --force-update
"jetstack" has been added to your repositories% helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.17.0 \
--set crds.enabled=true
NAME: cert-manager
LAST DEPLOYED: Sat Apr 12 14:08:13 2025
NAMESPACE: cert-manager
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
cert-manager v1.17.0 has been deployed successfully!- Login to your GitHub account and Navigate to "Create new Token."
- Select repo.
- Click Generate Token and then copy the token locally ( weβll need it later).
- Make a copy the
.env.samplenamed.env, and past your new token as the value of theGH_RUNNER_PATlocal environment variable.
% helm repo add actions-runner-controller https://actions-runner-controller.github.io/actions-runner-controller
"actions-runner-controller" has been added to your repositories% helm upgrade --install --namespace actions-runner-system --create-namespace\
--set=authSecret.create=true\
--set=authSecret.github_token="$GH_RUNNER_PAT"\
--wait actions-runner-controller actions-runner-controller/actions-runner-controller
Release "actions-runner-controller" does not exist. Installing it now.
NAME: actions-runner-controller
LAST DEPLOYED: Sat Apr 12 14:45:04 2025
NAMESPACE: actions-runner-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace actions-runner-system -l "app.kubernetes.io/name=actions-runner-controller,app.kubernetes.io/instance=actions-runner-controller" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace actions-runner-system $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace actions-runner-system port-forward $POD_NAME 8080:$CONTAINER_PORTThis will create the actions-runner-system namespace. In the next step, we will deploy our runner to that same actions-runner-system namespace.
Create a runnerdeployment.yaml file:
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: self-hosted-runnerdeploy
spec:
replicas: 1
template:
spec:
repository: loickreitmann/python-appApply it with kubectl into your cluster within the actions-runner-system namespace.
% kubectl apply -n actions-runner-system -f github/runnerdeployment.yaml
runnerdeployment.actions.summerwind.dev/self-hosted-runnerdeploy created% kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echoSave the resulting output as the ARGOCD_ADMIN_PASSWORD variable in your .env file.
% argocd login argocd-server.local --insecure --grpc-web --skip-test-tls --grpc-web-root-path "argocd" --username admin --password '$ARGOCD_ADMIN_PASSWORD'