kubernetes

install flannel

1
2
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
sysctl net.bridge.bridge-nf-call-iptables=1 (sur tous les noeuds)

exemple de création de pods avec port exposé

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
selector:
matchLabels:
run: load-balancer-example
replicas: 2
template:
metadata:
labels:
run: load-balancer-example
spec:
containers:
- name: hello-world
image: gcr.io/google-samples/node-hello:1.0
ports:
- containerPort: 8080
protocol: TCP
1
kubectl expose deployment hello-world --type=NodePort --name=example-service

kubernetes UI

Accéder à l’UI via un tunnel SSH

  • Installation:

    1
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta1/aio/deploy/recommended.yaml
  • Lancer l’UI:

    1
    kubectl proxy
  • Créer le tunnel:
    ssh -L 9999:127.0.0.1:8001 -N -f -l pi 192.168.1.101

  • Connection http:
    http://127.0.0.1:9999/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login

  • Récupérer le token:

    1
    kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

    Autoriser l’éxécution de pods sur le noeud master

    1
    kubectl taint nodes --all node-role.kubernetes.io/master-

    Metallb

    1
    kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml

    metallb-config.yaml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    apiVersion: v1
    kind: ConfigMap
    metadata:
    namespace: metallb-system
    name: config
    data:
    config: |
    address-pools:
    - name: default
    protocol: layer2
    addresses:
    - 192.168.1.170-192.168.1.190
  • Aprés avoir changé la plage d’IP il faut supprimer les podfs metallb: kubectl delete po -n metallb-system --all

Ingress Nginx

1
2
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
$ kubectl get pods -n ingress-nginx

GlusterFS

https://www.supinfo.com/articles/single/4441-kubernetes-stockage-demande-avec-heketi

wget https://github.com/heketi/heketi/releases/download/v4.0.0/heketi-v4.0.0.linux.arm.tar.gz

tar zxvf heketi-v4.0.0.linux.arm.tar.gz

pi@p-pi3b-0001:~/heketi $ ./heketi-cli -v
heketi-cli v4.0.0

sudo mkdir -p /etc/glusterfs /var/lib/misc/glusterfsd /var/lib/{heketi,glusterd} /var/log/glusterfs

curl -O https://raw.githubusercontent.com/gluster/gluster-kubernetes/master/deploy/kube-templates/glusterfs-daemonset.yaml

pi@p-pi3b-0001:~ $ kubectl label nodes p-pi3b-000{2,3}.hedwy.fr storageNode=GlusterFS
node/p-pi3b-0002.hedwy.fr labeled
node/p-pi3b-0003.hedwy.fr labeled

attention l’image docker officielle “gluster/gluster-centos” n’est pas compatible armhf

sed -i “20s/storagenode:\ glusterfs/storageNode:\ GlusterFS/g;s/gluster/gluster-centos:latest/angelnu/glusterfs/g” glusterfs-daemonset.yaml

pi@p-pi3b-0001:~ $ kubectl create -f glusterfs-daemonset.yaml
daemonset.extensions/glusterfs created

Liens:

https://github.com/teamserverless/k8s-on-raspbian/blob/master/GUIDE.md