树莓派集群安装rpi-busybox-httpd测试服务

一 配置安装

apiVersion: v1
kind: Namespace
metadata:
  name: k3s-demo           #自定义的命名空间

---
apiVersion: v1
kind: Service
metadata:
  name: httpdemo
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    nodePort: 31000
    protocol: TCP
    name: port
  type: NodePort
  selector:
    app: httpdemo
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: httpdemo
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: httpdemo
    spec:
      containers:
        - name: server
          image: hypriot/rpi-busybox-httpd
          ports:
            - containerPort: 80

运行命令: kubectl create -f httpd

集群内任意IP地址均可访问测试网站


二 遗留问题

Error from server (Invalid): error when creating "httpd/httpd.yaml": Service "httpdemo" is invalid: spec.ports[0].nodePort: Invalid value: 8000: provided port is not in the valid range. The range of valid ports is 30000-32767

三参考

  • k8s中的几个port
  • 浅谈 kubernetes service 那些事(上篇)
    *浅谈 kubernetes service 那些事 (下篇
    *从外部访问Kubernetes中的Pod
    *K8s nodePort、port、targetPort、hostPort

你可能感兴趣的:(树莓派集群安装rpi-busybox-httpd测试服务)