K8s/Ingress: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Line 8: Line 8:
==Internal==
==Internal==
{|
{|
|valign='top'|
|colspan='3'|
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
kubectl get ns|grep internal
kubectl get ns|grep internal
Line 16: Line 16:


|-
|-
|colspan='2'|
|colspan='3'|
----
----
|-
|-
|valign='top'|
|colspan='3'|
<syntaxhighlight lang="yaml">
<syntaxhighlight lang="yaml">
cat << YML|kubectl apply -n internal -f -
cat << YML|kubectl apply -n internal -f -
Line 36: Line 36:
   type: ExternalName
   type: ExternalName
   externalName: host.minikube.internal
   externalName: host.minikube.internal
YML
</syntaxhighlight>
|-
|colspan='3'|
----
|-
|valign='top'|
<syntaxhighlight lang="yaml">
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
YML
</syntaxhighlight>
</syntaxhighlight>
Line 75: Line 109:
YML
YML
</syntaxhighlight>
</syntaxhighlight>
|valign='top'|


|}
|}

Revision as of 10:08, 14 August 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: 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

Playground

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 all
kubectl get ns

References