Compare commits
9 Commits
82b4704f13
...
master
Author | SHA1 | Date | |
---|---|---|---|
350f17fd36 | |||
822cd4a3ef | |||
5366d94508 | |||
94fff2eb22 | |||
839104e6d8 | |||
dd0b70e779 | |||
1fb2dcf040 | |||
768935528b | |||
5188b5b65e |
@@ -17,7 +17,7 @@ system_info:
|
|||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
- mkdir -p /home/ubuntu/.kube /home/ubuntu/.config/fish/completions
|
- mkdir -p /home/ubuntu/.kube /home/ubuntu/.config/fish/completions
|
||||||
- microk8s alias microk8s.kubectl kubectl
|
- snap alias microk8s.kubectl kubectl
|
||||||
- kubectl completion fish > /home/ubuntu/.config/fish/completions/kubectl.fish
|
- kubectl completion fish > /home/ubuntu/.config/fish/completions/kubectl.fish
|
||||||
- chown -R ubuntu:ubuntu /home/ubuntu/.kube /home/ubuntu/.config/fish
|
- chown -R ubuntu:ubuntu /home/ubuntu/.kube /home/ubuntu/.config/fish
|
||||||
- microk8s enable dns ingress dashboard helm helm3
|
- microk8s enable dns ingress dashboard helm helm3
|
@@ -1,11 +1,25 @@
|
|||||||
|
# K8s setup with Nignx Ingress
|
||||||
|
|
||||||
|
```kubectl apply -f k8s/ingress```
|
||||||
|
|
||||||
|
Edit hosts file on host machine
|
||||||
|
|
||||||
|
Get ip of vm
|
||||||
|
|
||||||
|
```ip -o a | grep ens```
|
||||||
|
|
||||||
|
```sudo nano /etc/hosts```
|
||||||
|
|
||||||
|
```<ip> ingress.local```
|
||||||
|
|
||||||
|
http://ingress.local
|
||||||
|
|
||||||
|
http://ingress.local/v2
|
||||||
|
|
||||||
|
|
||||||
|
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#server-side-https-enforcement-through-redirect
|
||||||
|
|
||||||
https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
|
https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
|
||||||
|
|
||||||
```kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0```
|
https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/
|
||||||
|
|
||||||
```kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:2.0 --replicas=3```
|
|
||||||
|
|
||||||
```kubectl expose deployment web --type=NodePort --port=8080```
|
|
||||||
|
|
||||||
```kubectl expose deployment web2 --type=ClusterIP --port=8080```
|
|
||||||
|
|
||||||
```kubectl get service web```
|
|
||||||
|
19
ingress/web-deplyment.yaml
Normal file
19
ingress/web-deplyment.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: web
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
run: web
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
run: web
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: web
|
||||||
|
image: gcr.io/google-samples/hello-app:1.0
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
@@ -1,13 +1,14 @@
|
|||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: example-ingress
|
name: web-ingress
|
||||||
annotations:
|
annotations:
|
||||||
nginx.ingress.kubernetes.io/rewrite-target: /$1
|
nginx.ingress.kubernetes.io/rewrite-target: /$1
|
||||||
|
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||||
|
nginx.ingress.kubernetes.io/preserve-trailing-slash: "true"
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: hello-world.info
|
- http:
|
||||||
http:
|
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
@@ -23,4 +24,7 @@ spec:
|
|||||||
service:
|
service:
|
||||||
name: web2
|
name: web2
|
||||||
port:
|
port:
|
||||||
number: 8080
|
number: 8080
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- ingress.local
|
12
ingress/web-service.yaml
Normal file
12
ingress/web-service.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: web
|
||||||
|
labels:
|
||||||
|
run: web
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 8080
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
run: web
|
19
ingress/web2-deplyment.yaml
Normal file
19
ingress/web2-deplyment.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: web2
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
run: web2
|
||||||
|
replicas: 3
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
run: web2
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: web2
|
||||||
|
image: gcr.io/google-samples/hello-app:2.0
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
12
ingress/web2-service.yaml
Normal file
12
ingress/web2-service.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: web2
|
||||||
|
labels:
|
||||||
|
run: web2
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 8080
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
run: web2
|
1
letsencrypt/README.md
Normal file
1
letsencrypt/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
https://stackoverflow.com/questions/67430592/how-to-setup-letsencrypt-with-kubernetes-microk8s-using-default-ingress
|
24
letsencrypt/ingress-routes.yaml
Normal file
24
letsencrypt/ingress-routes.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: ingress-routes
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
#change to your domain
|
||||||
|
- k8s.technical.kiwi
|
||||||
|
secretName: tls-secret
|
||||||
|
rules:
|
||||||
|
#change yourdomain.com to your domain
|
||||||
|
- host: k8s.technical.kiwi
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: webserver-svc
|
||||||
|
port:
|
||||||
|
number: 80
|
15
letsencrypt/letsencrypt-prod.yaml
Normal file
15
letsencrypt/letsencrypt-prod.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: letsencrypt-prod
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
|
#change to your email
|
||||||
|
email: admin@technical.kiwi
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: letsencrypt-prod
|
||||||
|
solvers:
|
||||||
|
- http01:
|
||||||
|
ingress:
|
||||||
|
class: public
|
15
letsencrypt/letsencrypt-staging.yaml
Normal file
15
letsencrypt/letsencrypt-staging.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: letsencrypt-staging
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
#change to your email
|
||||||
|
email: admin@technical.kiwi
|
||||||
|
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: letsencrypt-staging
|
||||||
|
solvers:
|
||||||
|
- http01:
|
||||||
|
ingress:
|
||||||
|
class: public
|
29
letsencrypt/webserver-depl-svc.yaml
Normal file
29
letsencrypt/webserver-depl-svc.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: webserver-depl
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: webserver-app
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: webserver-app
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: webserver-app
|
||||||
|
image: nginx:1.8
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: webserver-svc
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: webserver-app
|
||||||
|
ports:
|
||||||
|
- name: webserver-app
|
||||||
|
protocol: TCP
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
Reference in New Issue
Block a user