general_manifests.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. Copyright 2021 The Rook Authors. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package installer
  14. import (
  15. "strconv"
  16. )
  17. func GetPodWithVolume(podName, claimName, namespace, mountPath string, readOnly bool) string {
  18. return `
  19. apiVersion: v1
  20. kind: Pod
  21. metadata:
  22. name: ` + podName + `
  23. namespace: ` + namespace + `
  24. spec:
  25. containers:
  26. - name: ` + podName + `
  27. image: busybox
  28. command: ["/bin/sleep", "infinity"]
  29. imagePullPolicy: IfNotPresent
  30. volumeMounts:
  31. - mountPath: ` + mountPath + `
  32. name: csivol
  33. volumes:
  34. - name: csivol
  35. persistentVolumeClaim:
  36. claimName: ` + claimName + `
  37. readOnly: ` + strconv.FormatBool(readOnly) + `
  38. restartPolicy: Never
  39. `
  40. }
  41. func GetPVC(claimName, namespace, storageClassName, accessModes, size string) string {
  42. return `apiVersion: v1
  43. kind: PersistentVolumeClaim
  44. metadata:
  45. name: ` + claimName + `
  46. namespace: ` + namespace + `
  47. spec:
  48. storageClassName: ` + storageClassName + `
  49. accessModes:
  50. - ` + accessModes + `
  51. resources:
  52. requests:
  53. storage: ` + size
  54. }
  55. func GetPVCRestore(claimName, snapshotName, namespace, storageClassName, accessModes, size string) string {
  56. return `apiVersion: v1
  57. kind: PersistentVolumeClaim
  58. metadata:
  59. name: ` + claimName + `
  60. namespace: ` + namespace + `
  61. spec:
  62. storageClassName: ` + storageClassName + `
  63. dataSource:
  64. name: ` + snapshotName + `
  65. kind: VolumeSnapshot
  66. apiGroup: snapshot.storage.k8s.io
  67. accessModes:
  68. - ` + accessModes + `
  69. resources:
  70. requests:
  71. storage: ` + size
  72. }
  73. func GetPVCClone(cloneClaimName, parentClaimName, namespace, storageClassName, accessModes, size string) string {
  74. return `apiVersion: v1
  75. kind: PersistentVolumeClaim
  76. metadata:
  77. name: ` + cloneClaimName + `
  78. namespace: ` + namespace + `
  79. spec:
  80. storageClassName: ` + storageClassName + `
  81. dataSource:
  82. name: ` + parentClaimName + `
  83. kind: PersistentVolumeClaim
  84. accessModes:
  85. - ` + accessModes + `
  86. resources:
  87. requests:
  88. storage: ` + size
  89. }
  90. func GetSnapshot(snapshotName, claimName, snapshotClassName, namespace string) string {
  91. return `apiVersion: snapshot.storage.k8s.io/v1
  92. kind: VolumeSnapshot
  93. metadata:
  94. name: ` + snapshotName + `
  95. namespace: ` + namespace + `
  96. spec:
  97. volumeSnapshotClassName: ` + snapshotClassName + `
  98. source:
  99. persistentVolumeClaimName: ` + claimName
  100. }