K8s/Ingress: Difference between revisions
Jump to navigation
Jump to search
(12 intermediate revisions by the same user not shown) | |||
Line 44: | Line 44: | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
===Internal » HAProxy=== | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat << YML | kubectl apply -n internal -f - | cat << YML | kubectl apply -n internal -f - | ||
Line 50: | Line 51: | ||
kind: Ingress | kind: Ingress | ||
metadata: | metadata: | ||
name: | name: haproxy | ||
namespace: internal | namespace: internal | ||
labels: | labels: | ||
Line 69: | Line 70: | ||
name: minikube-host | name: minikube-host | ||
port: | port: | ||
number: | number: 80 | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
===Internal » Apache=== | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
cat << YML | kubectl apply -n internal -f - | cat << YML | kubectl apply -n internal -f - | ||
Line 80: | Line 82: | ||
kind: Ingress | kind: Ingress | ||
metadata: | metadata: | ||
name: | name: apache | ||
namespace: internal | namespace: internal | ||
labels: | labels: | ||
Line 90: | Line 92: | ||
ingressClassName: nginx | ingressClassName: nginx | ||
rules: | rules: | ||
- host: " | - host: "apache.host.k8s.local" | ||
http: | http: | ||
paths: | paths: | ||
Line 99: | Line 101: | ||
name: minikube-host | name: minikube-host | ||
port: | port: | ||
number: | number: 2013 | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="yaml | ===Internal » Nginx=== | ||
<syntaxhighlight lang="yaml" line> | |||
cat << YML | kubectl apply -n internal -f - | cat << YML | kubectl apply -n internal -f - | ||
--- | --- | ||
Line 110: | Line 113: | ||
kind: Ingress | kind: Ingress | ||
metadata: | metadata: | ||
name: | name: nginx | ||
namespace: internal | namespace: internal | ||
labels: | labels: | ||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/managed-by: kubectl | |||
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 120: | Line 123: | ||
ingressClassName: nginx | ingressClassName: nginx | ||
rules: | rules: | ||
- host: " | - host: "nginx.host.k8s.local" | ||
http: | http: | ||
paths: | paths: | ||
- path: / | - path: / | ||
pathType: | pathType: ImplementationSpecific | ||
backend: | backend: | ||
service: | service: | ||
name: minikube-host | name: minikube-host | ||
port: | port: | ||
number: | number: 2015 | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 138: | Line 141: | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
===Internal » GitLab=== | |||
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
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 | |||
</syntaxhighlight> | |||
|valign='top'| | |||
===Internal » MinIO=== | |||
<syntaxhighlight lang="yaml" highlight="14,18,28" line> | |||
cat << YML | kubectl apply -n internal -f - | cat << YML | kubectl apply -n internal -f - | ||
--- | --- | ||
Line 151: | Line 186: | ||
app.kubernetes.io/name: minikube-host | app.kubernetes.io/name: minikube-host | ||
app.kubernetes.io/instance: minikube-host | app.kubernetes.io/instance: minikube-host | ||
annotations: | |||
nginx.ingress.kubernetes.io/proxy-body-size: '0' | |||
spec: | spec: | ||
ingressClassName: nginx | ingressClassName: nginx | ||
Line 164: | Line 201: | ||
port: | port: | ||
number: 9801 | number: 9801 | ||
- path: | - host: "s3.host.k8s.local" | ||
http: | |||
paths: | |||
- path: / | |||
pathType: ImplementationSpecific | pathType: ImplementationSpecific | ||
backend: | backend: | ||
Line 173: | Line 213: | ||
YML | YML | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
Line 184: | Line 222: | ||
|valign='top'| | |valign='top'| | ||
===ConfigMap » tcp-services=== | ===ConfigMap » tcp-services=== | ||
<syntaxhighlight lang="yaml" highlight="6,13-14" | <syntaxhighlight lang="yaml" highlight="6,13-14"> | ||
cat << YML | kubectl apply -n ingress-nginx -f - | cat << YML | kubectl apply -n ingress-nginx -f - | ||
--- | --- | ||
Line 401: | Line 439: | ||
* [https://docs.k0sproject.io/v1.27.1+k0s.0/examples/metallb-loadbalancer/ K8s » Ingress » MetalLB] | * [https://docs.k0sproject.io/v1.27.1+k0s.0/examples/metallb-loadbalancer/ K8s » Ingress » MetalLB] | ||
* [https://docs.k0sproject.io/v1.27.1+k0s.0/examples/traefik-ingress/ K8s » Ingress » Traefik] | * [https://docs.k0sproject.io/v1.27.1+k0s.0/examples/traefik-ingress/ K8s » Ingress » Traefik] | ||
* [[K8s/Swiss Knife|K8s » Swiss Knife]] | |||
* [[K8s/Service|K8s » Service]] | |||
* [[K8s/Run|K8s » Run]] | |||
|valign='top'| | |valign='top'| | ||
* [https://medium.com/@luis.laredo.vel/configuring-pgadmin-to-access-the-backstage-databases-in-a-kubernetes-cluster-953ee087e41d K8s » Configuring PgAdmin4] | |||
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]] | |||
|- | |- | ||
Line 421: | Line 464: | ||
|valign='top'| | |valign='top'| | ||
* [https://www.uptimia.com/questions/how-to-change-the-default-port-for-nginx Nginx » Change The Default Port] | |||
* [[Minikube Ingress DNS|Minikube » Ingress » DNS]] | * [[Minikube Ingress DNS|Minikube » Ingress » DNS]] | ||
* [[Minikube Systemd|Minikube » Systemd]] | * [[Minikube Systemd|Minikube » Systemd]] | ||
* [[Minikube Registry|Minikube » Registry]] | * [[Minikube Registry|Minikube » Registry]] | ||
* [[Minikube Tunnel|Minikube » Tunnel]] | |||
* [[Kubectl]] | * [[Kubectl]] | ||
* [[Ansible]] | * [[Ansible]] | ||
Line 431: | Line 476: | ||
|valign='top'| | |valign='top'| | ||
* [https://support.severalnines.com/hc/en-us/articles/212427063 Apache » Change The Default Port] | |||
|} | |} |
Latest revision as of 17:23, 16 November 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
| ||
| ||
Internal » HAProxycat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: haproxy
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: 80
YML
|
Internal » Apachecat << 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: "apache.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 2013
YML
|
Internal » Nginxcat << YML | kubectl apply -n internal -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
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: "nginx.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 2015
YML
|
| ||
Internal » GitLabcat << 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
|
Internal » MinIOcat << 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
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: '0'
spec:
ingressClassName: nginx
rules:
- host: "minio.host.k8s.local"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: minikube-host
port:
number: 9801
- host: "s3.host.k8s.local"
http:
paths:
- path: /
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 |