Skip to content

Instantly share code, notes, and snippets.

@DrMartiner
Last active January 7, 2023 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrMartiner/d8eceb2bca0ef1c9ae6f851696eb21b5 to your computer and use it in GitHub Desktop.
Save DrMartiner/d8eceb2bca0ef1c9ae6f851696eb21b5 to your computer and use it in GitHub Desktop.
k8s
helm install first-release nginx-stable/nginx-ingress -n nginx-ingres
kubectl create ns test1
kubectl apply -f deployment.yaml service.yml ingress.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test1
namespace: test1
spec:
selector:
matchLabels:
app: test1
template:
metadata:
labels:
app: test1
spec:
containers:
- name: test1
image: nginx:latest
imagePullPolicy: Always
ports:
- containerPort: 80
lifecycle:
postStart:
exec:
command: ["/bin/bash", "-c", "echo 'myhost.com' > /usr/share/nginx/html/index.html"]
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test1-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: myhost.com # add myhost.com to /etc/hosts
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: test1-service
port:
number: 80
apiVersion: v1
kind: Service
metadata:
name: test1-service
namespace: test1
labels:
app: test1
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
name: http
selector:
app: test1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment