Skip to main content

Addons

image.png

MicroK8s utiliza el mínimo de componentes para un Kubernetes puro y ligero. Sin embargo, hay muchas funciones adicionales disponibles  "addons": componentes preconfigurados que proporcionarán capacidades adicionales.

Para empezar, se recomienda añadir la gestión de DNS para facilitar la comunicación entre servicios.

Host único: el complemento «hostpath-storage» proporciona espacio de directorio en el host.

microk8s enable dns
microk8s enable hostpath-storage # solo host único

Dashboard

El panel estándar de Kubernetes es una forma conveniente de realizar un seguimiento de la actividad y el uso de recursos de MicroK8.

# Instala el Addon
microk8s enable dashboard

# Genera un token para validarte en el Dashboard
microk8s kubectl create token default

# Redirige un puerto del host para poder acceder al dashboard
microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443 --address 0.0.0.0

Ingress

Este complemento añade un controlador de entrada NGINX para MicroK8. Se habilita ejecutando el comando:

microk8s enable ingress

Con Ingress habilitado, se puede crear una regla de tipo "ingress" HTTP/HTTPS. por ejemplo:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: http-ingress
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: some-service
            port:
              number: 80

Cert-Manager

image.png

Cert-Manager es la solución estándar para la gestión de certificados en clústeres de Kubernetes.

microk8s enable cert-manager

Waiting for cert-manager to be ready.
..ready
Enabled cert-manager

===========================

Cert-manager is installed. As a next step, try creating an Issuer
for

ClusterIssuer

Se utiliza un recurso ClusterIssuer para configurar una cuenta con Let's EncryptEncrypt. bySolo creatingnecesita theuna followingdirección resource:de $correo microk8selectrónico kubectl(asegúrese applyde usar una válida).Global -f> -para <<EOFtodo ---el clúster

  • Se aplica una sola vez y puedes usarlo en cualquier namespace.

  • Ideal para producción cuando quieres certificados automáticos a nivel de clúster.

Manifiesto "letsencrypt-staging.yaml"

apiVersion: cert-manager.io/v1
kind: IssuerClusterIssuer
metadata:
  name: letsencryptletsencrypt-staging
spec:
  acme:
    # YouThe mustACME replaceserver thisURL
    emailserver: https://acme-staging-v02.api.letsencrypt.org/directory
    # Email address withused yourfor own.ACME registration
    email: user@example.com
    # Let'sName Encryptof willa usesecret thisused to contactstore youthe aboutACME expiringaccount private key
    privateKeySecretRef:
      name: letsencrypt-staging
    # certificates,Enable andthe issuesHTTP-01 relatedchallenge toprovider
    yoursolvers:
      account.- email:http01:
          me@example.comingress:
            class: nginx

Manifiesto "letsencrypt-prod.yaml":

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    # The ACME server URL
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:# Email address used for ACME registration
    email: user@example.com
    # SecretName resourceof thata will besecret used to store the account'sACME account private key.key
    privateKeySecretRef:
      name: letsencrypt-account-keyprod
    # AddEnable athe singleHTTP-01 challenge solver, HTTP01 using nginxprovider
    solvers:
      - http01:
          ingress:
            ingressClassName:class: nginx
EOF
Then,
you
can

Comprobación

create
# anLista ingress to expose 'my-service:80' on 'https://my-service.example.com' with:

$ microk8s enable ingress
$ microk8sClusterIssuers
kubectl createget ingressclusterissuer

my-ingress# \Obtener --annotationdetalles cert-manager.io/issuer=letsencryptdel \ClusterIssuer
--rulekubectl 'my-service.example.com/*=my-service:80,tls=my-service-tls'describe clusterissuer letsencrypt-staging
kubectl describe clusterissuer letsencrypt-prod