|
1 | 1 | ---
|
2 |
| - |
3 | 2 | title: 改变默认 StorageClass
|
4 | 3 | content_type: task
|
5 | 4 | ---
|
6 | 5 |
|
7 | 6 | <!-- overview -->
|
8 |
| - |
| 7 | +<!-- |
| 8 | +This page shows how to change the default Storage Class that is used to |
| 9 | +provision volumes for PersistentVolumeClaims that have no special requirements. |
| 10 | +--> |
9 | 11 | 本文展示了如何改变默认的 Storage Class,它用于为没有特殊需求的 PersistentVolumeClaims 配置 volumes。
|
10 | 12 |
|
11 |
| - |
12 |
| - |
13 | 13 | ## {{% heading "prerequisites" %}}
|
14 | 14 |
|
15 |
| - |
16 | 15 | {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
17 | 16 |
|
18 |
| - |
19 |
| - |
20 | 17 | <!-- steps -->
|
21 | 18 |
|
22 |
| - |
23 |
| -## 为什么要改变默认 storage class? |
24 |
| - |
25 |
| - |
26 |
| -取决于安装模式,您的 Kubernetes 集群可能和一个被标记为默认的已有 StorageClass 一起部署。这个默认的 StorageClass 以后将被用于动态的为没有特定 storage class 需求的 PersistentVolumeClaims 配置存储。更多细节请查看 [PersistentVolumeClaim 文档](/docs/user-guide/persistent-volumes/#class-1)。 |
27 |
| - |
28 |
| - |
29 |
| -预先安装的默认 StorageClass 可能不能很好的适应您期望的工作负载;例如,它配置的存储可能太过昂贵。如果是这样的话,您可以改变默认 StorageClass,或者完全禁用它以防止动态配置存储。 |
30 |
| - |
31 |
| - |
32 |
| -简单的删除默认 StorageClass 可能行不通,因为它可能会被您集群中的扩展管理器自动重建。请查阅您的安装文档中关于扩展管理器的细节,以及如何禁用单个扩展。 |
33 |
| - |
34 |
| - |
| 19 | +<!-- |
| 20 | +## Why change the default storage class? |
| 21 | +
|
| 22 | +Depending on the installation method, your Kubernetes cluster may be deployed with |
| 23 | +an existing StorageClass that is marked as default. This default StorageClass |
| 24 | +is then used to dynamically provision storage for PersistentVolumeClaims |
| 25 | +that do not require any specific storage class. See |
| 26 | +[PersistentVolumeClaim documentation](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) |
| 27 | +for details. |
| 28 | +--> |
| 29 | +## 为什么要改变默认存储类? |
| 30 | + |
| 31 | +取决于安装模式,你的 Kubernetes 集群可能和一个被标记为默认的已有 StorageClass 一起部署。 |
| 32 | +这个默认的 StorageClass 以后将被用于动态的为没有特定存储类需求的 PersistentVolumeClaims |
| 33 | +配置存储。更多细节请查看 [PersistentVolumeClaim 文档](/zh/docs/user-guide/persistent-volumes/#class-1)。 |
| 34 | + |
| 35 | +<!-- |
| 36 | +The pre-installed default StorageClass may not fit well with your expected workload; |
| 37 | +for example, it might provision storage that is too expensive. If this is the case, |
| 38 | +you can either change the default StorageClass or disable it completely to avoid |
| 39 | +dynamic provisioning of storage. |
| 40 | +--> |
| 41 | +预先安装的默认 StorageClass 可能不能很好的适应你期望的工作负载;例如,它配置的存储可能太过昂贵。 |
| 42 | +如果是这样的话,你可以改变默认 StorageClass,或者完全禁用它以防止动态配置存储。 |
| 43 | + |
| 44 | +<!-- |
| 45 | +Simply deleting the default StorageClass may not work, as it may be re-created |
| 46 | +automatically by the addon manager running in your cluster. Please consult the docs for your installation |
| 47 | +for details about addon manager and how to disable individual addons. |
| 48 | +--> |
| 49 | +简单的删除默认 StorageClass 可能行不通,因为它可能会被你集群中的扩展管理器自动重建。 |
| 50 | +请查阅你的安装文档中关于扩展管理器的细节,以及如何禁用单个扩展。 |
| 51 | + |
| 52 | + |
| 53 | +<!-- |
| 54 | +## Changing the default StorageClass |
| 55 | +--> |
35 | 56 | ## 改变默认 StorageClass
|
36 | 57 |
|
| 58 | +<!-- |
| 59 | +1. List the StorageClasses in your cluster: |
| 60 | +--> |
| 61 | +1. 列出你的集群中的 StorageClasses: |
37 | 62 |
|
38 |
| -1. 列出您集群中的 StorageClasses: |
39 |
| - |
40 |
| - ```bash |
41 |
| - kubectl get storageclass |
42 |
| - ``` |
| 63 | + ```shell |
| 64 | + kubectl get storageclass |
| 65 | + ``` |
43 | 66 |
|
44 |
| - 输出类似这样: |
| 67 | + 输出类似这样: |
45 | 68 |
|
46 |
| - ```bash |
47 |
| - NAME PROVISIONER AGE |
48 |
| - standard (default) kubernetes.io/gce-pd 1d |
49 |
| - gold kubernetes.io/gce-pd 1d |
50 |
| - ``` |
51 |
| - |
52 |
| - 默认 StorageClass 以 `(default)` 标记。 |
| 69 | + ```bash |
| 70 | + NAME PROVISIONER AGE |
| 71 | + standard (default) kubernetes.io/gce-pd 1d |
| 72 | + gold kubernetes.io/gce-pd 1d |
| 73 | + ``` |
53 | 74 |
|
| 75 | + 默认 StorageClass 以 `(default)` 标记。 |
54 | 76 |
|
| 77 | +<!-- |
| 78 | +1. Mark the default StorageClass as non-default: |
| 79 | +--> |
55 | 80 | 2. 标记默认 StorageClass 非默认:
|
| 81 | + |
| 82 | + <!-- |
| 83 | + The default StorageClass has an annotation |
| 84 | + `storageclass.kubernetes.io/is-default-class` set to `true`. Any other value |
| 85 | + or absence of the annotation is interpreted as `false`. |
56 | 86 |
|
| 87 | + To mark a StorageClass as non-default, you need to change its value to `false`: |
| 88 | + --> |
| 89 | + 默认 StorageClass 的注解 `storageclass.kubernetes.io/is-default-class` 设置为 `true`。 |
| 90 | + 注解的其它任意值或者缺省值将被解释为 `false`。 |
57 | 91 |
|
58 |
| - 默认 StorageClass 的注解 `storageclass.kubernetes.io/is-default-class` 设置为 `true`。注解的其它任意值或者缺省值将被解释为 `false`。 |
59 |
| - |
60 |
| - 要标记一个 StorageClass 为非默认的,您需要改变它的值为 `false`: |
| 92 | + 要标记一个 StorageClass 为非默认的,你需要改变它的值为 `false`: |
61 | 93 |
|
62 |
| - ```bash |
63 |
| - kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}' |
64 |
| - ``` |
65 |
| - |
66 |
| - |
67 |
| - 这里的 `<your-class-name>` 是您选择的 StorageClass 的名字。 |
68 |
| - |
69 |
| - |
| 94 | + ```bash |
| 95 | + kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}' |
| 96 | + ``` |
| 97 | + |
| 98 | + <!-- |
| 99 | + where `standard` is the name of your chosen StorageClass. |
| 100 | + --> |
| 101 | + 这里的 `standard` 是你选择的 StorageClass 的名字。 |
| 102 | + |
| 103 | +<!-- |
| 104 | +1. Mark a StorageClass as default: |
| 105 | +--> |
70 | 106 | 3. 标记一个 StorageClass 为默认的:
|
71 | 107 |
|
72 |
| - |
73 |
| - 和前面的步骤类似,您需要添加/设置注解 `storageclass.kubernetes.io/is-default-class=true`。 |
74 |
| - |
75 |
| - ```bash |
76 |
| - kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' |
77 |
| - ``` |
78 |
| - |
79 |
| - 请注意,最多只能有一个 StorageClass 能够被标记为默认。如果它们中有两个或多个被标记为默认,Kubernetes 将忽略这个注解,也就是它将表现为没有默认 StorageClass。 |
80 |
| - |
81 |
| - |
82 |
| -4. 验证您选用的 StorageClass 为默认的: |
83 |
| - |
84 |
| - ```bash |
85 |
| - kubectl get storageclass |
86 |
| - ``` |
87 |
| - |
88 |
| - 输出类似这样: |
89 |
| - |
90 |
| - ```bash |
91 |
| - NAME PROVISIONER AGE |
92 |
| - standard kubernetes.io/gce-pd 1d |
93 |
| - gold (default) kubernetes.io/gce-pd 1d |
94 |
| - ``` |
95 |
| - |
96 |
| - |
| 108 | + <!-- |
| 109 | + Similarly to the previous step, you need to add/set the annotation |
| 110 | + `storageclass.kubernetes.io/is-default-class=true`. |
| 111 | + --> |
| 112 | + 和前面的步骤类似,你需要添加/设置注解 `storageclass.kubernetes.io/is-default-class=true`。 |
| 113 | + |
| 114 | + ```bash |
| 115 | + kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' |
| 116 | + ``` |
| 117 | + |
| 118 | + <!-- |
| 119 | + Please note that at most one StorageClass can be marked as default. If two |
| 120 | + or more of them are marked as default, a `PersistentVolumeClaim` without |
| 121 | + `storageClassName` explicitly specified cannot be created. |
| 122 | + --> |
| 123 | + 请注意,最多只能有一个 StorageClass 能够被标记为默认。 |
| 124 | + 如果它们中有两个或多个被标记为默认,Kubernetes 将忽略这个注解, |
| 125 | + 也就是它将表现为没有默认 StorageClass。 |
| 126 | + |
| 127 | +<!-- |
| 128 | +1. Verify that your chosen StorageClass is default: |
| 129 | +--> |
| 130 | +4. 验证你选用的 StorageClass 为默认的: |
| 131 | + |
| 132 | + ```bash |
| 133 | + kubectl get storageclass |
| 134 | + ``` |
| 135 | + |
| 136 | + <!-- |
| 137 | + The output is similar to this: |
| 138 | + --> |
| 139 | + 输出类似这样: |
| 140 | + |
| 141 | + ```bash |
| 142 | + NAME PROVISIONER AGE |
| 143 | + standard kubernetes.io/gce-pd 1d |
| 144 | + gold (default) kubernetes.io/gce-pd 1d |
| 145 | + ``` |
97 | 146 |
|
98 | 147 | ## {{% heading "whatsnext" %}}
|
99 | 148 |
|
100 |
| - |
101 |
| -* 了解更多关于 [StorageClasses](/docs/concepts/storage/persistent-volumes/)。 |
102 |
| - |
103 |
| - |
| 149 | +<!-- |
| 150 | +* Learn more about [PersistentVolumes](/docs/concepts/storage/persistent-volumes/). |
| 151 | +--> |
| 152 | +* 进一步了解 [StorageClasses](/docs/concepts/storage/persistent-volumes/) |
104 | 153 |
|
0 commit comments