Skip to content

Instantly share code, notes, and snippets.

@arellano-gustavo
Last active October 26, 2022 02:48
Show Gist options
  • Save arellano-gustavo/19aa1e87ea7434eccbdd3e4b8de12899 to your computer and use it in GitHub Desktop.
Save arellano-gustavo/19aa1e87ea7434eccbdd3e4b8de12899 to your computer and use it in GitHub Desktop.
Prueba sencilla de microk8s con una imagen de Spark

Instrucciones

1  mkdir project
2  cd project
3  nano app.yaml
4  nano store-ssl-cert.sh
5  nano create-secret.sh
6  nano server.key
7  nano server.crt
8  chmod 700 *.sh
9  echo "-------------------------"
10  sudo apt update
11  sudo snap install microk8s --classic
12  sudo usermod -a -G microk8s ubuntu
13  exit
14  microk8s enable dns ingress registry storage
15  echo "-------------------------"
16  ./create-secret.sh 
17  ./store-ssl-cert.sh 
18  microk8s kubectl apply -f app.yaml
19  microk8s kubectl get pods -A

Files store-ssl-cert.sh AND create-secret.sh resp:

microk8s kubectl create secret tls hello-app-tls \
    --namespace default \
    --key server.key \
    --cert server.crt
    
microk8s kubectl create secret docker-registry goose-github \
    --docker-server=ghcr.io \
    --docker-username=miguel-hidalgo \
    --docker-password=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxx \
    [email protected]

Nota para usuarios de LetsEncrypt:

  • usar en vez de server.key el archivo private.key de letsEncrypt
  • y usar en vez de server.crt el archivo cert.pem de LetsEncrypt
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo-microk8s-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
tls:
- hosts:
- access.pbits.mx
secretName: hello-app-tls
rules:
- host: access.qbits.mx
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: demo-microk8s
port:
number: 9999
ingressClassName: nginx
---
kind: Service
apiVersion: v1
metadata:
name: demo-microk8s
labels:
app: demo-microk8s
spec:
type: ClusterIP
selector:
app: demo-microk8s
ports:
- port: 9999
targetPort: 9999
name: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-microk8s
labels:
app: demo-microk8s
spec:
selector:
matchLabels:
octopusexport: OctopusExport
replicas: 5
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: demo-microk8s
octopusexport: OctopusExport
spec:
imagePullSecrets:
- name: goose-github
containers:
- name: demo-microk8s
image: ghcr.io/qbits-mx/dockerized-access:latest
env:
- name: SPC
value: https://config.qbits.mx
imagePullPolicy: Always
ports:
- name: http
containerPort: 9999
protocol: TCP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment