K8s/Ingress: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 444: Line 444:


|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]]
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]]


Line 463: 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]]
Line 474: 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 » HAProxy

cat << 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 » Apache

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: "apache.host.k8s.local"
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: minikube-host
                port:
                  number: 2013
YML

Internal » Nginx

cat << 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 » GitLab

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

Internal » MinIO

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
  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-services

cat << 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-services

cat << 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-nginx

cat << 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

References