Skip to content

Commit 4982a50

Browse files
anwarchkRyan Baxter
authored and
Ryan Baxter
committed
README update for ConfigMap reload sample (spring-cloud#401)
* Updated README with the following: 1. Fixed small typos 2. Removed notes about Spring Boot liveness and readiness check related to Fabric8 since that issue has been resolved and is working as expected 3. Added sample configuration files for K8s RBAC set up required for the example to work 4. Added section about how to setup RBAC config * Updated sample RBAC configuration with a less privileged role example
1 parent 92813c0 commit 4982a50

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

spring-cloud-kubernetes-examples/kubernetes-reload-example/README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ To play with these examples, you can install locally Kubernetes & Docker using `
55
managed by a hypervisor (Xhyve, Virtualbox or KVM) if your machine is not a native Unix operating system.
66

77

8-
When the minikube is installed on your machine, you can start kubernetes using this command:
8+
When the Minikube is installed on your machine, you can start kubernetes using this command:
99
```
1010
minikube start
1111
```
1212

13-
You also probably want to configure your docker client to point the minikube docker deamon with:
13+
You also probably want to configure your docker client to point the Minikube docker daemon with:
1414
```
1515
eval $(minikube docker-env)
1616
```
1717

18-
This will make sure that the docker images that you build are available to the minikube environment.
18+
This will make sure that the docker images that you build are available to the Minikube environment.
1919

2020
## Kubernetes Reload Example
2121

@@ -31,10 +31,6 @@ Once you have your environment set up, you can deploy the application using the
3131
mvn clean install fabric8:build fabric8:deploy -Pintegration
3232
```
3333

34-
**Note**: Unfortuntaly, when you deploy using the fabric8 plugin, the readyness and liveness probes fail to point to the right actuator URL due a lack of support for spring boot.
35-
This push you to edit the generated deployment inside kubernetes and change these probes which points to "path": "/health" to "path": "/actuator/health".
36-
This will make your deployment go green. This issue is already reported into the fabric8 community: https://github.com/fabric8io/fabric8-maven-plugin/issues/1178
37-
3834
### Changing the configuration
3935

4036
Create a yaml file with the following contents:
@@ -68,3 +64,40 @@ kubectl edit configmap reload-example
6864
Changes are applied immediately when using the *event* reload mode.
6965

7066
The name of the config map (*"reload-example"*) matches the name of the application as declared in the *application.properties* file.
67+
68+
**Note**: If you are running in a Kubernetes environment where [RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) is enabled, you need to make sure that your pod has the right level of authorizations to access the K8s APIs or resources.
69+
To help you get started, a sample `ServiceAccount` and `RoleBinding` configuration is provided in `src/k8s` directory. These configuration needs to be applied to your K8s cluster and the newly created `ServiceAccount` needs to be attached to your pod spec like this:
70+
71+
```yml
72+
spec:
73+
containers:
74+
image: <image_loc>
75+
imagePullPolicy: IfNotPresent
76+
livenessProbe:
77+
failureThreshold: 3
78+
httpGet:
79+
path: /actuator/health
80+
port: 8080
81+
scheme: HTTP
82+
initialDelaySeconds: 180
83+
successThreshold: 1
84+
name: spring-boot
85+
ports:
86+
- containerPort: 8080
87+
name: http
88+
protocol: TCP
89+
- containerPort: 9779
90+
name: prometheus
91+
protocol: TCP
92+
readinessProbe:
93+
failureThreshold: 3
94+
httpGet:
95+
path: /actuator/health
96+
port: 8080
97+
scheme: HTTP
98+
initialDelaySeconds: 10
99+
successThreshold: 1
100+
securityContext:
101+
privileged: false
102+
serviceAccountName: <service_account_name>
103+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
name: pod-reader
5+
namespace: default
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: Role
9+
name: pod-reader
10+
subjects:
11+
- kind: ServiceAccount
12+
name: config-reader
13+
namespace: default
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
namespace: default
5+
name: pod-reader
6+
rules:
7+
- apiGroups: [""]
8+
resources: ["pods","configmaps"]
9+
verbs: ["get", "watch", "list"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: config-reader
5+
namespace: default

0 commit comments

Comments
 (0)