-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Kuber-2024-04OTUS/kubernetes-csi
Kubernetes csi
- Loading branch information
Showing
10 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: csi-s3 | ||
namespace: kube-system | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: csi-s3 | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: csi-s3 | ||
subjects: | ||
- kind: ServiceAccount | ||
name: csi-s3 | ||
namespace: kube-system | ||
roleRef: | ||
kind: ClusterRole | ||
name: csi-s3 | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
kind: DaemonSet | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: csi-s3 | ||
namespace: kube-system | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: csi-s3 | ||
template: | ||
metadata: | ||
labels: | ||
app: csi-s3 | ||
spec: | ||
tolerations: | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
- operator: Exists | ||
effect: NoExecute | ||
tolerationSeconds: 300 | ||
serviceAccount: csi-s3 | ||
containers: | ||
- name: driver-registrar | ||
image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0 | ||
args: | ||
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)" | ||
- "--v=4" | ||
- "--csi-address=$(ADDRESS)" | ||
env: | ||
- name: ADDRESS | ||
value: /csi/csi.sock | ||
- name: DRIVER_REG_SOCK_PATH | ||
value: /var/lib/kubelet/plugins/ru.yandex.s3.csi/csi.sock | ||
- name: KUBE_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- name: plugin-dir | ||
mountPath: /csi | ||
- name: registration-dir | ||
mountPath: /registration/ | ||
- name: csi-s3 | ||
securityContext: | ||
privileged: true | ||
capabilities: | ||
add: ["SYS_ADMIN"] | ||
allowPrivilegeEscalation: true | ||
image: cr.yandex/crp9ftr22d26age3hulg/csi-s3:0.41.1 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "--endpoint=$(CSI_ENDPOINT)" | ||
- "--nodeid=$(NODE_ID)" | ||
- "--v=4" | ||
env: | ||
- name: CSI_ENDPOINT | ||
value: unix:///csi/csi.sock | ||
- name: NODE_ID | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- name: plugin-dir | ||
mountPath: /csi | ||
- name: stage-dir | ||
mountPath: /var/lib/kubelet/plugins/kubernetes.io/csi | ||
mountPropagation: "Bidirectional" | ||
- name: pods-mount-dir | ||
mountPath: /var/lib/kubelet/pods | ||
mountPropagation: "Bidirectional" | ||
- name: fuse-device | ||
mountPath: /dev/fuse | ||
- name: systemd-control | ||
mountPath: /run/systemd | ||
volumes: | ||
- name: registration-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins_registry/ | ||
type: DirectoryOrCreate | ||
- name: plugin-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins/ru.yandex.s3.csi | ||
type: DirectoryOrCreate | ||
- name: stage-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins/kubernetes.io/csi | ||
type: DirectoryOrCreate | ||
- name: pods-mount-dir | ||
hostPath: | ||
path: /var/lib/kubelet/pods | ||
type: Directory | ||
- name: fuse-device | ||
hostPath: | ||
path: /dev/fuse | ||
- name: systemd-control | ||
hostPath: | ||
path: /run/systemd | ||
type: DirectoryOrCreate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-with-csi | ||
labels: | ||
app: nginx-with-csi | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nginx-with-csi | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx-with-csi | ||
spec: | ||
containers: | ||
- name: nginx-with-csi | ||
image: nginx | ||
volumeMounts: | ||
- mountPath: /usr/share/nginx/html/ | ||
name: csi | ||
volumes: | ||
- name: csi | ||
persistentVolumeClaim: | ||
claimName: kube-csi-s3-pvc | ||
readOnly: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: CSIDriver | ||
metadata: | ||
name: ru.yandex.s3.csi | ||
spec: | ||
attachRequired: false | ||
podInfoOnMount: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: csi-s3-provisioner-sa | ||
namespace: kube-system | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: csi-s3-external-provisioner-runner | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["secrets"] | ||
verbs: ["get", "list"] | ||
- apiGroups: [""] | ||
resources: ["persistentvolumes"] | ||
verbs: ["get", "list", "watch", "create", "delete"] | ||
- apiGroups: [""] | ||
resources: ["persistentvolumeclaims"] | ||
verbs: ["get", "list", "watch", "update"] | ||
- apiGroups: ["storage.k8s.io"] | ||
resources: ["storageclasses"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: [""] | ||
resources: ["events"] | ||
verbs: ["list", "watch", "create", "update", "patch"] | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: csi-s3-provisioner-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: csi-s3-provisioner-sa | ||
namespace: kube-system | ||
roleRef: | ||
kind: ClusterRole | ||
name: csi-s3-external-provisioner-runner | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: csi-s3-provisioner | ||
namespace: kube-system | ||
labels: | ||
app: csi-s3-provisioner | ||
spec: | ||
selector: | ||
app: csi-s3-provisioner | ||
ports: | ||
- name: csi-s3-dummy | ||
port: 65535 | ||
--- | ||
kind: StatefulSet | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: csi-s3-provisioner | ||
namespace: kube-system | ||
spec: | ||
serviceName: "csi-provisioner-s3" | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: csi-s3-provisioner | ||
template: | ||
metadata: | ||
labels: | ||
app: csi-s3-provisioner | ||
spec: | ||
serviceAccount: csi-s3-provisioner-sa | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
- key: CriticalAddonsOnly | ||
operator: Exists | ||
containers: | ||
- name: csi-provisioner | ||
image: quay.io/k8scsi/csi-provisioner:v2.1.0 | ||
args: | ||
- "--csi-address=$(ADDRESS)" | ||
- "--v=4" | ||
env: | ||
- name: ADDRESS | ||
value: /var/lib/kubelet/plugins/ru.yandex.s3.csi/csi.sock | ||
imagePullPolicy: "IfNotPresent" | ||
volumeMounts: | ||
- name: socket-dir | ||
mountPath: /var/lib/kubelet/plugins/ru.yandex.s3.csi | ||
- name: csi-s3 | ||
image: cr.yandex/crp9ftr22d26age3hulg/csi-s3:0.41.1 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "--endpoint=$(CSI_ENDPOINT)" | ||
- "--nodeid=$(NODE_ID)" | ||
- "--v=4" | ||
env: | ||
- name: CSI_ENDPOINT | ||
value: unix:///var/lib/kubelet/plugins/ru.yandex.s3.csi/csi.sock | ||
- name: NODE_ID | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
- name: socket-dir | ||
mountPath: /var/lib/kubelet/plugins/ru.yandex.s3.csi | ||
volumes: | ||
- name: socket-dir | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: kube-csi-s3-pvc | ||
namespace: default | ||
spec: | ||
accessModes: | ||
- ReadWriteMany | ||
resources: | ||
requests: | ||
storage: 5Gi | ||
storageClassName: kube-csi-s3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
1) создаю секрет с ключами для доступа к ObjectStorage | ||
kubectl apply -f .\secret.yaml | ||
2) создаю starageClass, описывающий класс хранилища: | ||
kubectl apply -f .\storage-class.yaml | ||
3) установка драйвера: | ||
kubectl apply -f provisioner.yaml | ||
kubectl apply -f driver.yaml | ||
kubectl apply -f csi-s3.yaml | ||
4) создание pvc: | ||
kubectl apply -f pvc.yaml | ||
5) создать под, который будет использовать objectstorage: | ||
kubectl apply -f .\deployment.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
namespace: kube-system | ||
name: kube-csi-s3-secret | ||
stringData: | ||
accessKeyID: key-id | ||
secretAccessKey: secret | ||
endpoint: https://storage.yandexcloud.net/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: kube-csi-s3 | ||
provisioner: ru.yandex.s3.csi | ||
parameters: | ||
mounter: geesefs | ||
options: "--memory-limit=1000 --dir-mode=0777 --file-mode=0666" | ||
bucket: kubernetes-csi | ||
csi.storage.k8s.io/provisioner-secret-name: kube-csi-s3-secret | ||
csi.storage.k8s.io/provisioner-secret-namespace: kube-system | ||
csi.storage.k8s.io/controller-publish-secret-name: kube-csi-s3-secret | ||
csi.storage.k8s.io/controller-publish-secret-namespace: kube-system | ||
csi.storage.k8s.io/node-stage-secret-name: kube-csi-s3-secret | ||
csi.storage.k8s.io/node-stage-secret-namespace: kube-system | ||
csi.storage.k8s.io/node-publish-secret-name: kube-csi-s3-secret | ||
csi.storage.k8s.io/node-publish-secret-namespace: kube-system |
Binary file not shown.
Binary file not shown.