K3S搭建

本次搭建环境为 CentOS Linux release 7.9.2009

第一步:

curl -sfL http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -

第二步:

安装完毕 输入命令查看 kubectl get node

显示如下表示安装成功

NAME                      STATUS   ROLES                  AGE     VERSION
izm5ea80v3kwetdisrcfmtz   Ready    control-plane,master   3m15s   v1.23.6+k3s1

编辑个应用试试

首先创建一个k3s的目录

然后在当前目录下创建deploy.yaml文件内容如下

##deploy.yaml
#deployment
kind: Deployment
apiVersion: apps/v1
metadata:
  name: test
  namespace: default
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: test
          image: nginx:alpine
          ports:
            - name: tcp-80
              containerPort: 80
              protocol: TCP
          resources: {}
          imagePullPolicy: IfNotPresent
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  progressDeadlineSeconds: 600
---
#service
kind: Service
apiVersion: v1
metadata:
  name: test
  namespace: default
  labels:
    app: test
spec:
  ports:
    - name: http-80
      protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30010
  selector:
    app: test
  type: NodePort

 执行命令

kubectl apply -f deploy.yaml

浏览器访问:本机IP:30010

页面显示

K3S搭建_第1张图片

说明配置成功 

你可能感兴趣的:(golang,K3S,linux,运维,服务器)