-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create example for issues spring-projects/spring-boot#26627
- Loading branch information
Showing
5 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# Spring Boot Prometheus Bug | ||
# Spring Boot Bug | ||
|
||
Refers to issue: https://github.com/spring-projects/spring-boot/issues/26627 | ||
|
||
How to run it: | ||
- Make sure to have kind installed and create the cluster using kind-with-registry.sh | ||
- Build the docker image with `./gradlew jibDockerBuild` | ||
- Run the following docker commands to make the image available in the cluster | ||
- `docker tag spring-boot-bug:2.4.6 localhost:5000/spring-boot-bug:2.4.6` | ||
- `docker push localhost:5000/spring-boot-bug:2.4.6` | ||
- Apply the k8s resources with: | ||
- `kubectl -f apply kubernetes/configmap` | ||
- `kubectl -f apply kubernetes/deployment` | ||
|
||
To build the image for a different version of spring-boot: | ||
- Change the `version` in the `build.gradle.kts` file | ||
- Change the `image` tag in the `kubernetes/deployment.yaml` file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
set -o errexit | ||
|
||
# create registry container unless it already exists | ||
reg_name='kind-registry' | ||
reg_port='5000' | ||
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" | ||
if [ "${running}" != 'true' ]; then | ||
docker run \ | ||
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \ | ||
registry:2 | ||
fi | ||
|
||
# create a cluster with the local registry enabled in containerd | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"] | ||
endpoint = ["http://${reg_name}:${reg_port}"] | ||
EOF | ||
|
||
# connect the registry to the cluster network | ||
# (the network may already be connected) | ||
docker network connect "kind" "${reg_name}" || true | ||
|
||
# Document the local registry | ||
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "localhost:${reg_port}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: spring-boot-application | ||
labels: | ||
app: spring-boot-application | ||
data: | ||
application-kubernetes.yml: | | ||
server.port: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: spring-boot-application | ||
labels: | ||
app: spring-boot-application | ||
spec: | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 0 | ||
type: RollingUpdate | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: spring-boot-application | ||
template: | ||
metadata: | ||
labels: | ||
app: spring-boot-application | ||
spec: | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 65534 | ||
runAsGroup: 65534 | ||
# needed because of https://github.com/aws/amazon-eks-pod-identity-webhook/issues/8 | ||
fsGroup: 65534 | ||
containers: | ||
- name: spring-boot-application | ||
image: "localhost:5000/spring-boot-bug:2.4.6" | ||
imagePullPolicy: Always | ||
env: | ||
- name: JAVA_TOOL_OPTIONS | ||
value: "-XX:+UseContainerSupport -XX:InitialRAMPercentage=50 -XX:MaxRAMPercentage=80" | ||
- name: SPRING_PROFILES_ACTIVE | ||
value: "kubernetes" | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
livenessProbe: | ||
failureThreshold: 5 | ||
httpGet: | ||
path: /actuator/health/liveness | ||
port: http | ||
initialDelaySeconds: 10 | ||
periodSeconds: 3 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
failureThreshold: 5 | ||
httpGet: | ||
path: /actuator/health/readiness | ||
port: http | ||
initialDelaySeconds: 10 | ||
periodSeconds: 3 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
volumeMounts: | ||
- name: tmp | ||
mountPath: /tmp | ||
- name: spring-boot-application | ||
mountPath: /config | ||
readOnly: true | ||
securityContext: | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
restartPolicy: Always | ||
volumes: | ||
- name: tmp | ||
emptyDir: { } | ||
- name: spring-boot-application | ||
configMap: | ||
name: spring-boot-application |