K8s/Ingress: Difference between revisions
Jump to navigation
Jump to search
Line 104: | Line 104: | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml" highlight="8,9,19,20" line> | ||
cat << YML | kubectl apply -n internal -f - | cat << YML | kubectl apply -n internal -f - | ||
--- | --- | ||
Line 112: | Line 112: | ||
name: pgadmin | name: pgadmin | ||
namespace: internal | namespace: internal | ||
annotations: | |||
nginx.ingress.kubernetes.io/rewrite-target: /pgadmin4 | |||
labels: | labels: | ||
app.kubernetes.io/name: minikube-host | app.kubernetes.io/name: minikube-host | ||
app.kubernetes.io/instance: minikube-host | app.kubernetes.io/instance: minikube-host | ||
Line 123: | Line 123: | ||
http: | http: | ||
paths: | paths: | ||
- path: / | - path: / | ||
pathType: | pathType: Prefix | ||
backend: | backend: | ||
service: | service: |
Revision as of 09:04, 4 September 2024
External
kubectl get ns|grep external
kubectl delete namespace external
kubectl create namespace external
Internal
kubectl get ns|grep internal
kubectl delete namespace internal
kubectl create namespace internal
| ||
| ||
cat << YML|kubectl apply -n internal -f -
---
apiVersion: v1
kind: Service
metadata:
name: minikube-host
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
type: ExternalName
externalName: host.minikube.internal
YML
| ||
| ||
cat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: apache
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
ingressClassName: nginx
rules:
- host: "host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 2013
YML
|
cat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitlab
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
ingressClassName: nginx
rules:
- host: "gitlab.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 1080
YML
|
cat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pgadmin
namespace: internal
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /pgadmin4
labels:
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
ingressClassName: nginx
rules:
- host: "pgadmin.host.k8s.local"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: minikube-host
port:
number: 2013
YML
|
| ||
cat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minio
namespace: internal
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: minikube-host
app.kubernetes.io/instance: minikube-host
spec:
ingressClassName: nginx
rules:
- host: "minio.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 9801
- path: /files/
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 9800
YML
|
Ingress » Nginx
ConfigMap » tcp-servicescat << YML | kubectl apply -n ingress-nginx -f -
---
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: ingress-nginx
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
data:
5432: "postgresql/postgresql:5432"
6379: "redis/redis-headless:6379"
YML
|
ConfigMap » udp-servicescat << YML | kubectl apply -n ingress-nginx -f -
---
apiVersion: v1
kind: ConfigMap
metadata:
name: udp-services
namespace: ingress-nginx
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
data:
1194: "internal/minikube-host:1194"
53: "kube-system/kube-dns:53"
YML
|
| |
Service » ingress-nginxcat << YML | kubectl apply -n ingress-nginx -f -
---
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
- name: https
port: 443
targetPort: 443
protocol: TCP
- name: proxied-tcp-5432
port: 5432
targetPort: 5432
protocol: TCP
- name: proxied-tcp-6379
port: 6379
targetPort: 6379
protocol: TCP
- name: proxied-udp-1194
port: 1194
targetPort: 1194
protocol: UDP
- name: proxied-udp-53
port: 53
targetPort: 53
protocol: UDP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
YML
| |
| |
kubectl -n ingress-nginx rollout restart deploy/ingress-nginx-controller
kubectl -n ingress-nginx rollout history deploy/ingress-nginx-controller
kubectl -n ingress-nginx rollout status deploy/ingress-nginx-controller
|
Minikube » Tunnel
# check minikube user either exists or not
cat /etc/passwd|grep minikube
sudo usermod -aG sudo minikube
|
# minikube no-password sudo access add to EOL
sudo visudo
minikube ALL=(ALL) NOPASSWD: ALL
|
# login to minikube user and start tunneling
sudo -i -u minikube
minikube tunnel
|
Playground
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -- cat template/nginx.tmpl
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -- cat /etc/resolv.conf
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -- cat nginx.conf
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -- cat /etc/hosts
| ||
| ||
kubectl -n external get endpoints
kubectl -n external get service
kubectl -n external get ingress
|
kubectl -n internal get endpoints
kubectl -n internal get service
kubectl -n internal get ingress
|
kubectl config get-contexts
sudo -i -u minikube
helm list -A
|
| ||
kubectl get all -A
kubectl get ns
|
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -c controller -- bash
kubectl -n ingress-nginx exec -it svc/ingress-nginx-controller -- bash
| |
| ||
sudo vim /etc/apache2/sites-enabled/000-default.conf sudo vim /etc/apache2/ports.conf sudo apachectl -t |
sudo systemctl restart apache2.service sudo systemctl reload apache2.service systemctl status apache2.service |