Created
July 11, 2019 06:45
-
-
Save RICH0423/e1f0b7ad0c18432d2d3840f372c8d1cd to your computer and use it in GitHub Desktop.
Run a Nginx application on K8S (using Minikube)
This file contains hidden or 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: nginx-deployment # Deployment name | |
spec: | |
selector: # defines how the Deployment finds which Pods to manage | |
matchLabels: | |
app: nginx | |
replicas: 2 | |
template: # The Pods are labeled app:nginx using the labels field | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
containers: # indicates that the Pods run one container, nginx at version 1.7.9 | |
- name: my-nginx | |
image: nginx:1.9.1 | |
ports: | |
- containerPort: 80 | |
--- | |
kind: Service | |
apiVersion: v1 | |
metadata: | |
name: nginx-service | |
spec: | |
type: NodePort | |
ports: | |
- protocol: TCP | |
port: 8080 | |
targetPort: 80 #each pods expose port 80 | |
nodePort: 30002 | |
selector: | |
app: nginx |
This file contains hidden or 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
#!/bin/bash | |
kubectl apply -f nginx-deployment.yaml | |
kubectl get svc | |
minikube service nginx-service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx, this is just a simple example