Last active
February 8, 2023 06:34
-
-
Save mbigras/9e12a2027374569073eb979b17994f69 to your computer and use it in GitHub Desktop.
This file contains 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
Build mbigras/blueapp:v1 Docker image. | |
cat <<'Dockerfile' | docker build -t mbigras/blueapp:v1 - | |
# syntax=docker/dockerfile:1.3-labs see https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ | |
FROM python | |
RUN pip install flask gunicorn | |
RUN cat <<App >app.py | |
import os | |
from flask import Flask, jsonify | |
app = Flask("blueapp") | |
@app.route("/") | |
def ui(): | |
return jsonify( | |
color=os.environ["COLOR"], | |
corners=os.environ["CORNERS"], | |
widgets=os.environ["WIDGETS"], | |
) | |
App | |
ENV PORT=8080 | |
ENTRYPOINT ["gunicorn", "app:app"] | |
Dockerfile | |
Run mbigras/blueapp:v1 Docker container. | |
docker run -it -p 8080:8080 -e COLOR=blue -e CORNERS=rounded -e WIDGETS=w1,w2,w3 mbigras/blueapp:v1 | |
$ curl localhost:8080 | |
{"color":"blue","corners":"rounded","widgets":"w1,w2,w3"} | |
This file contains 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
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: blueapp | |
spec: | |
selector: | |
matchLabels: | |
app: blueapp | |
replicas: 3 | |
template: | |
metadata: | |
labels: | |
app: blueapp | |
spec: | |
containers: | |
- name: blueapp | |
image: mbigras/blueapp:v1 | |
envFrom: | |
- configMapRef: | |
name: blueapp |
This file contains 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
kind: Kustomization | |
apiVersion: kustomize.config.k8s.io/v1beta1 | |
resources: | |
- deployment.yaml | |
configMapGenerator: | |
- name: blueapp | |
literals: | |
- COLOR=cornflowerblue | |
- CORNERS=rounded | |
- WIDGETS=w2,w1,w3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is for kubernetes/kubectl#686 (comment) comment.