惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Webroot Blog
Webroot Blog
T
The Blog of Author Tim Ferriss
S
Schneier on Security
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
P
Palo Alto Networks Blog
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
量子位
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
Recorded Future
Recorded Future
K
Kaspersky official blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
Lohrmann on Cybersecurity
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
L
LINUX DO - 热门话题
Help Net Security
Help Net Security
B
Blog RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Cloudflare Blog
H
Heimdal Security Blog
Last Week in AI
Last Week in AI
美团技术团队
云风的 BLOG
云风的 BLOG
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
V
Visual Studio Blog
G
GRAHAM CLULEY
AI
AI
Security Latest
Security Latest
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed

jobcher on 打工人日志

2023-12-21 打工人日报 2023-12-20 打工人日报 2023-12-19 打工人日报 2023-12-18 打工人日报 2023-12-17 打工人日报 2023-12-16 打工人日报 2023-12-15 打工人日报 2023-12-14 打工人日报 2023-12-13 打工人日报 2023-12-12 打工人日报 2023-12-11 打工人日报 2023-12-10 打工人日报 2023-12-09 打工人日报 2023-12-08 打工人日报 2023-12-07 打工人日报 2023-12-06 打工人日报 2023-12-05 打工人日报 2023-12-04 打工人日报 2023-12-03 打工人日报 2023-12-02 打工人日报 2023-12-01 打工人日报 2023-11-30 打工人日报 2023-11-29 打工人日报 2023-11-28 打工人日报 2023-11-27 打工人日报 2023-11-26 打工人日报 2023-11-25 打工人日报 2023-11-24 打工人日报 2023-11-23 打工人日报 2023-11-22 打工人日报 2023-11-21 打工人日报 2023-11-20 打工人日报 2023-11-19 打工人日报 2023-11-17 打工人日报 2023-11-16 打工人日报 2023-11-15 打工人日报 2023-11-14 打工人日报 2023-11-13 打工人日报 2023-11-12 打工人日报 2023-11-11 打工人日报 2023-11-10 打工人日报 2023-11-09 打工人日报 2023-11-08 打工人日报 2023-11-07 打工人日报 2023-11-06 打工人日报 2023-11-05 打工人日报 2023-11-04 打工人日报 2023-11-03 打工人日报 2023-11-02 打工人日报 2023-11-01 打工人日报 2023-10-31 打工人日报 2023-10-30 打工人日报 2023-10-29 打工人日报 2023-10-28 打工人日报 2023-10-27 打工人日报 2023-10-26 打工人日报 2023-10-25 打工人日报 2023-10-24 打工人日报 2023-10-23 打工人日报 2023-10-22 打工人日报 2023-10-21 打工人日报 2023-10-20 打工人日报 2023-10-19 打工人日报 2023-10-18 打工人日报 2023-10-17 打工人日报 2023-10-16 打工人日报 2023-10-15 打工人日报 2023-10-14 打工人日报 2023-10-13 打工人日报 2023-10-12 打工人日报 2023-10-11 打工人日报 2023-10-10 打工人日报 2023-10-09 打工人日报 2023-10-07 打工人日报 2023-10-06 打工人日报 2023-10-05 打工人日报 2023-10-04 打工人日报 2023-10-03 打工人日报 2023-10-02 打工人日报 2023-10-01 打工人日报 2023-09-30 打工人日报 2023-09-29 打工人日报 2023-09-28 打工人日报 2023-09-27 打工人日报 2023-09-26 打工人日报 2023-09-25 打工人日报 2023-09-24 打工人日报 2023-09-23 打工人日报 2023-09-22 打工人日报 2023-09-21 打工人日报 2023-09-20 打工人日报 2023-09-19 打工人日报 2023-09-18 打工人日报 2023-09-17 打工人日报 2023-09-16 打工人日报 2023-09-15 打工人日报 2023-09-14 打工人日报 2023-09-13 打工人日报 2023-09-12 打工人日报 2023-09-11 打工人日报
Kubernetes 创建nfs存储类
2021-12-13 · via jobcher on 打工人日志

Kubernetes 创建 nfs 存储类

首先你需要在别的终端上创建 nfs 服务并能提供 nfs 访问
Kubernetes 不包含内部 NFS 驱动。你需要使用外部驱动为 NFS 创建 StorageClass。
https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner
安装 nfs 驱动

安装 nfs 驱动

1#安装nfs客户端
2apt-get install nfs-common
3git clone https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner.git
4cd nfs-subdir-external-provisioner/deploy
5k3s kubectl create -f rbac.yaml
6vim deployment.yaml
  1. 编辑 deployment.yaml
 1apiVersion: apps/v1
 2kind: Deployment
 3metadata:
 4  name: nfs-client-provisioner
 5  labels:
 6    app: nfs-client-provisioner
 7  # replace with namespace where provisioner is deployed
 8  namespace: default
 9spec:
10  replicas: 1
11  strategy:
12    type: Recreate
13  selector:
14    matchLabels:
15      app: nfs-client-provisioner
16  template:
17    metadata:
18      labels:
19        app: nfs-client-provisioner
20    spec:
21      serviceAccountName: nfs-client-provisioner
22      containers:
23        - name: nfs-client-provisioner
24          image: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
25          volumeMounts:
26            - name: nfs-client-root
27              mountPath: /persistentvolumes
28          env:
29            - name: PROVISIONER_NAME
30              value: k8s-sigs.io/nfs-subdir-external-provisioner
31            - name: NFS_SERVER
32              value: 192.168.99.235
33            - name: NFS_PATH
34              value: /volume2/nfs-k8s
35      volumes:
36        - name: nfs-client-root
37          nfs:
38            server: 192.168.99.235
39            path: /volume2/nfs-k8s
  1. 定义存储类
1k3s kubectl create -f deployment.yaml
2k3s kubectl create -f class.yaml

测试存储是否正常

1k3s kubectl create -f test-claim.yaml -f test-pod.yaml
2k3s kubectl delete -f test-claim.yaml -f test-pod.yaml

创建有状态 pods(mysql)

创建 mysql-deployment.yaml

 1apiVersion: v1
 2kind: Service
 3metadata:
 4  name: mysql
 5spec:
 6  ports:
 7    - port: 3306
 8      targetPort: 3306
 9  selector:
10    app: mysql
11  clusterIP: None
12  type: LoadBalancer
13---
14apiVersion: apps/v1
15kind: Deployment
16metadata:
17  name: mysql
18spec:
19  selector:
20    matchLabels:
21      app: mysql
22  strategy:
23    type: Recreate
24  template:
25    metadata:
26      labels:
27        app: mysql
28    spec:
29      containers:
30        - image: mysql:5.7
31          name: mysql
32          env:
33            # Use secret in real usage
34            - name: MYSQL_ROOT_PASSWORD
35              value: password
36          ports:
37            - containerPort: 3306
38              name: mysql
39          volumeMounts:
40            - name: mysql-persistent-storage
41              mountPath: /var/lib/mysql
42      volumes:
43        - name: mysql-persistent-storage
44          persistentVolumeClaim:
45            claimName: mysql-pv-claim

创建 mysql-pv.yaml

 1apiVersion: v1
 2kind: PersistentVolume
 3metadata:
 4  name: mysql-pv-volume
 5spec:
 6  storageClassName: managed-nfs-storage
 7  capacity:
 8    storage: 20Gi
 9  accessModes:
10    - ReadWriteOnce
11  nfs:
12    server: 192.168.99.235
13    path: "/volume2/nfs-k8s"
14---
15apiVersion: v1
16kind: PersistentVolumeClaim
17metadata:
18  name: mysql-pv-claim
19spec:
20  storageClassName: managed-nfs-storage
21  accessModes:
22    - ReadWriteMany
23  resources:
24    requests:
25      storage: 20Gi

部署 mysql

1k3s kubectl apply -f mysql-pv.yaml
2k3s kubectl apply -f mysql-deployment.yaml
3k3s kubectl describe deployment mysql