Skip to content

Commit

Permalink
fix: Modify indentation in yaml format
Browse files Browse the repository at this point in the history
  • Loading branch information
dyx1234 committed Oct 13, 2024
1 parent dadaef2 commit 4522dfd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
31 changes: 16 additions & 15 deletions docs/en/client/java-sdk-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,27 +446,27 @@ value: The content is the JSON format string of the corresponding configuration
How to authorize a Pod's Service Account to have read and write permissions for ConfigMap:

1. Create a Service Account: If there is no Service Account, you need to create one.
```
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-service-account
namespace: default
name: my-service-account
namespace: default
```
2. Create a Role or ClusterRole: Define a Role or ClusterRole to grant read and write permissions for a specific ConfigMap. If the ConfigMap is used across multiple Namespaces, a ClusterRole should be used.
```
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: configmap-role
namespace: default
name: configmap-role
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
```
3. Bind the Service Account to the Role or ClusterRole: Use RoleBinding or ClusterRoleBinding to bind the Service Account to the Role or ClusterRole created above.
```
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand All @@ -482,25 +482,26 @@ How to authorize a Pod's Service Account to have read and write permissions for
apiGroup: rbac.authorization.k8s.io
```
4. Specify the Service Account in the Pod configuration: Ensure that the Pod's configuration uses the Service Account created above.
```
```yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: default
name: my-pod
namespace: default
spec:
serviceAccountName: my-service-account
containers:
- name: my-container
image: my-image
serviceAccountName: my-service-account
containers:
- name: my-container
image: my-image
```
5. Apply the configuration: Use the kubectl command-line tool to apply these configurations.
```
```yaml
kubectl apply -f service-account.yaml
kubectl apply -f role.yaml
kubectl apply -f role-binding.yaml
kubectl apply -f pod.yaml
```

These steps give the Service Account in the Pod read and write permissions for the specified ConfigMap.
If the ConfigMap is cross-namespace, use ClusterRole and ClusterRoleBinding instead of Role and RoleBinding, and ensure that these configurations are applied in all Namespaces that need to access the ConfigMap.

Expand Down
32 changes: 15 additions & 17 deletions docs/zh/client/java-sdk-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,29 +429,27 @@ value:内容为对应的配置信息的json格式字符串
如何授权一个Pod的Service Account具有对ConfigMap的读写权限:
1. 创建Service Account: 如果还没有Service Account,你需要创建一个。
```
```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-service-account
namespace: default
name: my-service-account
namespace: default
```
2. 创建Role或ClusterRole: 定义一个Role或ClusterRole,授予对特定ConfigMap的读写权限。如果ConfigMap是跨多个Namespace使用的,应该使用ClusterRole。

```
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: configmap-role
namespace: default
name: configmap-role
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
```

3. 绑定Service Account到Role或ClusterRole: 使用RoleBinding或ClusterRoleBinding将Service Account绑定到上面创建的Role或ClusterRole。
```
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand All @@ -467,20 +465,20 @@ value:内容为对应的配置信息的json格式字符串
apiGroup: rbac.authorization.k8s.io
```
4. 在Pod配置中指定Service Account: 确保Pod的配置中使用了上面创建的Service Account。
```
```yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
namespace: default
name: my-pod
namespace: default
spec:
serviceAccountName: my-service-account
containers:
- name: my-container
image: my-image
serviceAccountName: my-service-account
containers:
- name: my-container
image: my-image
```
5. 应用配置: 使用kubectl命令行工具应用这些配置。
```
```yaml
kubectl apply -f service-account.yaml
kubectl apply -f role.yaml
kubectl apply -f role-binding.yaml
Expand Down

0 comments on commit 4522dfd

Please sign in to comment.