Cannot expose k3s services on Raspberry Pi

12/28/2019

I'm attempting to build a k3s cluster on 3 raspberry pis. All 3 are running the latest version on Raspbian Buster Lite. I deployed the k3s cluster and everything seems to work, and I seem to be able to begin deploying pods. I'm attempting to deploy a minimal Consul container and it works, but I cant seem to be able to expose it to the outside world (even to my local network).

At first I tried exposing it with traefik ingress, but when that did not work I wanted to see if exposing it with nodePort would work, but was surprised when that did not work either. Later I read that Kubernetes has issues with the latest version of IPtables (I saw that it does not write any rules to iptables-save, only to iptables-legacy), so I tried doing the following command:

update-alternatives --set iptables /usr/sbin/iptables-legacy

And re-deployed my pods, but to no avail. Has anyone encountered this before?

Here are the 2 yamls I used:

Without traefik:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul
  template:
    metadata:
      labels:
        app: consul
    spec:
      containers:
      - name: consul
        image: consul:latest
---
apiVersion: v1
kind: Service
metadata:
  name: consul
  namespace: default
spec:
  selector:
    app: consul
  type: NodePort
  ports:
  - name: http
    port: 8500
    targetPort: 8500
    nodePort: 30036
    protocol: TCP

With traefik:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul 
  template:
    metadata:
      labels:
        app: consul 
    spec:
      containers:
      - name: consul
        image: consul:latest
---
apiVersion: v1
kind: Service
metadata:
  name: consul
  namespace: default
spec:
  ports:
  - name: http
    targetPort: 8500
    port: 80
  selector:
    app: consul
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: consul
  annotations:
    kubernetes.io/ingress.class: "traefik"

spec:
  rules:
  - host: consul.example.org
    # I tried adding consul.example.org to my hosts file, but to no effect.
    http:
      paths:
      - path: /
        backend:
          serviceName: consul
          servicePort: http
-- Ripol
containers
docker
k3s
kubernetes
raspberry-pi

0 Answers