系统与环境
vmware ubuntu18
linux
docker 我写的教程
k3d+kubectl 我写的教程
步骤
根据网上的教程:https://github.com/rancher/k3d/blob/main/docs/usage/guides/exposing_services.md
- 创建1个server+2个agents的集群
k3d cluster create mycluster -p "8082:30080@agent[0]" --agents 2
- 创建nginx的pod
kubectl create deployment nginx --image=nginx:latest
- 根据[网上的教程](kubectl apply -f nginx-service.yaml service),service.yaml如下:
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx
spec:
ports:
- name: 80-80
nodePort: 30080
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
type: NodePort
kubectl apply -f nginx-service.yaml service
-
访问 localhost:8082
localhost指虚拟机的ip
网友评论