Skip to content

Instantly share code, notes, and snippets.

@RICH0423
Created July 11, 2019 06:45
Show Gist options
  • Save RICH0423/e1f0b7ad0c18432d2d3840f372c8d1cd to your computer and use it in GitHub Desktop.
Save RICH0423/e1f0b7ad0c18432d2d3840f372c8d1cd to your computer and use it in GitHub Desktop.
Run a Nginx application on K8S (using Minikube)
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
#!/bin/bash
kubectl apply -f nginx-deployment.yaml
kubectl get svc
minikube service nginx-service
@duckscofield
Copy link

太威了!

@RICH0423
Copy link
Author

太威了!

Thx, this is just a simple example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment