Last active
October 16, 2024 12:38
-
-
Save sdenel/1bd2c8b5975393ababbcff9b57784e82 to your computer and use it in GitHub Desktop.
Kubernetes: a simple Nginx "Hello world" deployment file
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
# To deploy: kubectl create -f nginx-hello-world-deployment.yaml | |
# Access it with the API as a proxy: | |
# $ kubectl proxy | |
# Then in you browser: http://localhost:8001/api/v1/namespaces/default/services/nginx:/proxy/#!/ | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx | |
spec: | |
type: NodePort | |
ports: | |
- port: 80 | |
targetPort: 80 | |
nodePort: 30001 | |
selector: | |
app: nginx | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-config | |
data: | |
nginx.conf: ' | |
events { | |
} | |
http { | |
server { | |
listen 80; | |
location / { | |
return 200 "Hello world!"; | |
} | |
} | |
} | |
' | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx | |
spec: | |
selector: | |
matchLabels: | |
app: nginx | |
strategy: | |
type: Recreate | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
containers: | |
- image: nginx:latest | |
name: nginx | |
ports: | |
- containerPort: 80 | |
name: web | |
volumeMounts: | |
- name: config-vol | |
mountPath: /etc/nginx/ | |
volumes: | |
- name: config-vol | |
configMap: | |
name: nginx-config | |
items: | |
- key: nginx.conf | |
path: nginx.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment