k8s - uncategorized notes

Page content

Terminology

  • SDS: Software Defined Storage
  • CRD: Custom Resource Definition (one of kubernetes term)

Text formatting of kubectl output

-o json, yaml, name, file

Ingerss

Install nginx ingress controller (official)

https://kubernetes.github.io/ingress-nginx/deploy/

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/deploy.yaml
  • All components are deployed in the namespace nginx-ingress.
  • Using nodeport.
  • It installs ingress-nginx Controller, not ingress..

https://kubernetes.github.io/ingress-nginx/deploy/baremetal/#using-a-self-provisioned-edge

connetct to the controller pod like kubectl exec --stdin --tty ingress-nginx-controller-75f84dfcd7-24vl4 -n ingress-nginx -- /bin/bash. You can find the nginx process is running.

bash-5.0$ ps
PID   USER     TIME  COMMAND
    1 www-data  0:00 /usr/bin/dumb-init -- /nginx-ingress-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=
    6 www-data  0:11 /nginx-ingress-controller --election-id=ingress-controller-leader --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-web
   25 www-data  0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
   37 www-data  0:01 nginx: worker process
   38 www-data  0:01 nginx: worker process
   39 www-data  0:00 nginx: cache manager process
  106 www-data  0:00 /bin/bash
  112 www-data  0:00 ps

Install Ingree with helm

https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-helm/

$ helm repo add nginx-stable https://helm.nginx.com/stable
$ helm repo update
helm install my-release nginx-stable/nginx-ingress

it will install in the namespace default.

NAME: my-release
LAST DEPLOYED: Fri Jun 19 08:23:33 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The ingress-nginx controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace default get services -o wide -w my-release-ingress-nginx-controller'

An example Ingress that makes use of the controller:

  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    annotations:
      kubernetes.io/ingress.class: nginx
    name: example
    namespace: foo
  spec:
    rules:
      - host: www.example.com
        http:
          paths:
            - backend:
                serviceName: exampleService
                servicePort: 80
              path: /
    # This section is only required if TLS is to be enabled for the Ingress
    tls:
        - hosts:
            - www.example.com
          secretName: example-tls

If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:

  apiVersion: v1
  kind: Secret
  metadata:
    name: example-tls
    namespace: foo
  data:
    tls.crt: <base64 encoded cert>
    tls.key: <base64 encoded key>
  type: kubernetes.io/tls

delete nginx-ingress installed by official command.

kubectl delete namespace ingress-nginx
kubectl delete clusterrole ingress-nginx
kubectl delete clusterrolebinding ingress-nginx
kubectl delete clusterrole ingress-nginx-admission

https://cyberagent.ai/blog/pr/kubernetes/3758/


cert-manager install with helm youtube issuer pod communicate with acme server create certificate in secret form rbac….

helm environment manager https://www.youtube.com/watch?v=fy8SHvNZGeE

autoscale https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ Horizontal Pod Autoscaler


DNS

default CoreDNS

https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#services

“Normal” (not headless) Services are assigned a DNS A or AAAA record, depending on the IP family of the service, for a name of the form my-svc.my-namespace.svc.cluster-domain.example

Go wrong

journalctl -u kubelet failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to read kubelet config file “/var/lib/kubelet/config.yaml restart servers and swapoff