-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
[Docs]OSPP Support Kubernetes ConfigMap for Apollo java, golang client #5233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
315e7f9
ef8c94f
9a1e7e2
811b6e2
dadaef2
4522dfd
4ca7b18
8a09176
63b196f
3acc36a
9799d52
f453422
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -163,6 +163,8 @@ request.timeout=2000 | |||||
| batch=2000 | ||||||
| ``` | ||||||
|
|
||||||
| > 注:如果部署在Kubernetes环境中,您还可以启用configMap缓存来进一步提高可用性 | ||||||
|
|
||||||
| #### 1.2.3.1 自定义缓存路径 | ||||||
|
|
||||||
| 1.0.0版本开始支持以下方式自定义缓存路径,按照优先级从高到低分别为: | ||||||
|
|
@@ -398,6 +400,94 @@ apollo.label=YOUR-APOLLO-LABEL | |||||
| 3. 通过`app.properties`配置文件 | ||||||
| * 可以在`classpath:/META-INF/app.properties`指定`apollo.override-system-properties=true` | ||||||
|
|
||||||
| #### 1.2.4.10 ConfigMap缓存设置 | ||||||
|
|
||||||
| > 适用于2.4.0及以上版本 | ||||||
|
|
||||||
| 在2.4.0版本开始,客户端在Kubernetes环境下的可用性得到了加强,开启configMap缓存后,客户端会将从服务端拉取到的配置信息在configMap中缓存一份,在服务不可用,或网络不通,且本地缓存文件丢失的情况下,依然能从configMap恢复配置。以下是相关配置 | ||||||
|
|
||||||
| `apollo.cache.kubernetes.enable`:是否开启configMap缓存机制,默认false | ||||||
|
|
||||||
| `apollo.cache.kubernetes.configmap-namespace`:将使用的configMap所在的namespace(Kubernetes中的namespace),默认值为"default" | ||||||
|
|
||||||
| 配置信息会以下面的对应关系放置于指定的configmap中: | ||||||
|
|
||||||
| namespace:使用指定的值,若未指定默认为"default" | ||||||
|
|
||||||
| configMapName:{appId} | ||||||
|
|
||||||
| key:{cluster}+{namespace} | ||||||
|
|
||||||
| value:内容为对应的配置信息的json格式字符串 | ||||||
|
|
||||||
|
|
||||||
| > appId是应用自己的appId,如100004458 | ||||||
| > cluster是应用使用的集群,一般在本地模式下没有做过配置的话,是default | ||||||
| > namespace就是应用使用的配置namespace,一般是application | ||||||
|
|
||||||
| > 由于需要对configmap进行读写操作,所以客户端所在pod必须有相应读写权限,具体配置方法可参考下文 | ||||||
|
|
||||||
| 如何授权一个Pod的Service Account具有对ConfigMap的读写权限: | ||||||
| 1. 创建Service Account: 如果还没有Service Account,你需要创建一个。 | ||||||
| ```yaml | ||||||
| apiVersion: v1 | ||||||
| kind: ServiceAccount | ||||||
| metadata: | ||||||
| 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 | ||||||
| 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: | ||||||
| name: configmap-reader-binding | ||||||
| namespace: dafault | ||||||
|
||||||
| subjects: | ||||||
| - kind: ServiceAccount | ||||||
| name: my-service-account | ||||||
| namespace: dafault | ||||||
|
||||||
| namespace: dafault | |
| namespace: default |
Uh oh!
There was an error while loading. Please reload this page.