├── .dockerignore
├── .gitignore
├── .helmignore
├── Dockerfile
├── Jenkinsfile
├── LICENSE
├── README.md
├── charts
├── preview
│ ├── Chart.yaml
│ ├── Makefile
│ ├── requirements.yaml
│ └── values.yaml
└── spring-cloud-k8s-minion
│ ├── .helmignore
│ ├── Chart.yaml
│ ├── Makefile
│ ├── README.md
│ ├── templates
│ ├── NOTES.txt
│ ├── _helpers.tpl
│ ├── deployment.yaml
│ ├── minion-config-map.yaml
│ ├── role-bindings.yaml
│ ├── role.yaml
│ ├── service.yaml
│ └── serviceaccount.yaml
│ └── values.yaml
├── pom.xml
├── skaffold.yaml
└── src
├── main
├── java
│ └── org
│ │ └── minions
│ │ └── demo
│ │ ├── Application.java
│ │ ├── BossClientService.java
│ │ ├── Controller.java
│ │ ├── MinionConfig.java
│ │ └── MinionsLibrary.java
└── resources
│ ├── application.properties
│ └── logback.xml
└── test
└── java
└── org
└── minions
└── demo
└── ApplicationTests.java
/.dockerignore:
--------------------------------------------------------------------------------
1 | draft.toml
2 | charts/
3 | NOTICE
4 | LICENSE
5 | README.md
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 |
3 | # Compiled class file
4 | *.class
5 |
6 | # Log file
7 | *.log
8 |
9 | # BlueJ files
10 | *.ctxt
11 |
12 | # Mobile Tools for Java (J2ME)
13 | .mtj.tmp/
14 |
15 | # Package Files #
16 | *.jar
17 | *.war
18 | *.ear
19 | *.zip
20 | *.tar.gz
21 | *.rar
22 |
23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24 | hs_err_pid*
25 |
26 | #IDE metadata
27 | **.idea/**
28 | .idea/
29 | *.iml
30 |
31 | # Eclipse
32 | .project
33 | .classpath
34 | .settings
--------------------------------------------------------------------------------
/.helmignore:
--------------------------------------------------------------------------------
1 | # Patterns to ignore when building packages.
2 | # This supports shell glob matching, relative path matching, and
3 | # negation (prefixed with !). Only one pattern per line.
4 | .DS_Store
5 | # Common VCS dirs
6 | .git/
7 | .gitignore
8 | .bzr/
9 | .bzrignore
10 | .hg/
11 | .hgignore
12 | .svn/
13 | # Common backup files
14 | *.swp
15 | *.bak
16 | *.tmp
17 | *~
18 | # Various IDEs
19 | .project
20 | .idea/
21 | *.tmproj
22 | *.png
23 |
24 | # known compile time folders
25 | target/
26 | node_modules/
27 | vendor/
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openjdk:8-jdk-alpine
2 | ENV PORT 8080
3 | EXPOSE 8080
4 | COPY target/*.jar /opt/app.jar
5 | WORKDIR /opt
6 | CMD ["java", "-jar", "app.jar"]
7 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent {
3 | label "jenkins-maven"
4 | }
5 | environment {
6 | ORG = 'salaboy'
7 | APP_NAME = 'spring-cloud-k8s-minion'
8 | CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
9 | }
10 | stages {
11 | stage('CI Build and push snapshot') {
12 | when {
13 | branch 'PR-*'
14 | }
15 | environment {
16 | PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
17 | PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
18 | HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
19 | }
20 | steps {
21 | container('maven') {
22 | sh "mvn versions:set -DnewVersion=$PREVIEW_VERSION"
23 | sh "mvn install"
24 | sh 'export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml'
25 |
26 |
27 | sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
28 | }
29 |
30 | dir ('./charts/preview') {
31 | container('maven') {
32 | sh "make preview"
33 | sh "jx preview --app $APP_NAME --dir ../.."
34 | }
35 | }
36 | }
37 | }
38 | stage('Build Release') {
39 | when {
40 | branch 'develop'
41 | }
42 | steps {
43 | container('maven') {
44 | // ensure we're not on a detached head
45 | sh "git checkout develop"
46 | sh "git config --global credential.helper store"
47 |
48 | sh "jx step git credentials"
49 | // so we can retrieve the version in later steps
50 | sh "echo \$(jx-release-version) > VERSION"
51 | sh "mvn versions:set -DnewVersion=\$(cat VERSION)"
52 | }
53 | dir ('./charts/spring-cloud-k8s-minion') {
54 | container('maven') {
55 | sh "make tag"
56 | }
57 | }
58 | container('maven') {
59 | sh 'mvn clean deploy'
60 |
61 | sh 'export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml'
62 |
63 |
64 | sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
65 | }
66 | }
67 | }
68 | stage('Promote to Environments') {
69 | when {
70 | branch 'develop'
71 | }
72 | steps {
73 | dir ('./charts/spring-cloud-k8s-minion') {
74 | container('maven') {
75 | sh 'jx step changelog --version v\$(cat ../../VERSION)'
76 |
77 | // release the helm chart
78 | sh 'jx step helm release'
79 |
80 | // promote through all 'Auto' promotion Environments
81 | sh 'jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)'
82 | }
83 | }
84 | }
85 | }
86 | }
87 | post {
88 | always {
89 | cleanWs()
90 | }
91 | failure {
92 | input """Pipeline failed.
93 | We will keep the build pod around to help you diagnose any failures.
94 |
95 | Select Proceed or Abort to terminate the build pod"""
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spring-cloud-k8s-minion
--------------------------------------------------------------------------------
/charts/preview/Chart.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | description: A Helm chart for Kubernetes
3 | icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/java.png
4 | name: preview
5 | version: 0.1.0-SNAPSHOT
6 |
--------------------------------------------------------------------------------
/charts/preview/Makefile:
--------------------------------------------------------------------------------
1 | OS := $(shell uname)
2 |
3 | preview:
4 | ifeq ($(OS),Darwin)
5 | sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml
6 | sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml
7 | sed -i "" -e "s/tag: .*/tag: $(PREVIEW_VERSION)/" values.yaml
8 | else ifeq ($(OS),Linux)
9 | sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml
10 | sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml
11 | sed -i -e "s/repository: .*/repository: $(DOCKER_REGISTRY)\/salaboy\/spring-cloud-k8s-minion/" values.yaml
12 | sed -i -e "s/tag: .*/tag: $(PREVIEW_VERSION)/" values.yaml
13 | else
14 | echo "platfrom $(OS) not supported to release from"
15 | exit -1
16 | endif
17 | echo " version: $(PREVIEW_VERSION)" >> requirements.yaml
18 | jx step helm build
19 |
--------------------------------------------------------------------------------
/charts/preview/requirements.yaml:
--------------------------------------------------------------------------------
1 |
2 | dependencies:
3 | - alias: expose
4 | name: exposecontroller
5 | repository: https://chartmuseum.build.cd.jenkins-x.io
6 | version: 2.3.56
7 | - alias: cleanup
8 | name: exposecontroller
9 | repository: https://chartmuseum.build.cd.jenkins-x.io
10 | version: 2.3.56
11 | - alias: preview
12 | name: spring-cloud-k8s-minion
13 | repository: file://../spring-cloud-k8s-minion
14 |
--------------------------------------------------------------------------------
/charts/preview/values.yaml:
--------------------------------------------------------------------------------
1 |
2 | expose:
3 | Annotations:
4 | helm.sh/hook: post-install,post-upgrade
5 | helm.sh/hook-delete-policy: hook-succeeded
6 | config:
7 | exposer: Ingress
8 | http: true
9 | tlsacme: false
10 |
11 | cleanup:
12 | Args:
13 | - --cleanup
14 | Annotations:
15 | helm.sh/hook: pre-delete
16 | helm.sh/hook-delete-policy: hook-succeeded
17 |
18 | preview:
19 | image:
20 | repository:
21 | tag:
22 | pullPolicy: IfNotPresent
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/.helmignore:
--------------------------------------------------------------------------------
1 | # Patterns to ignore when building packages.
2 | # This supports shell glob matching, relative path matching, and
3 | # negation (prefixed with !). Only one pattern per line.
4 | .DS_Store
5 | # Common VCS dirs
6 | .git/
7 | .gitignore
8 | .bzr/
9 | .bzrignore
10 | .hg/
11 | .hgignore
12 | .svn/
13 | # Common backup files
14 | *.swp
15 | *.bak
16 | *.tmp
17 | *~
18 | # Various IDEs
19 | .project
20 | .idea/
21 | *.tmproj
22 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/Chart.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | description: A Helm chart for Kubernetes
3 | icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/java.png
4 | name: spring-cloud-k8s-minion
5 | version: 0.1.0-SNAPSHOT
6 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/Makefile:
--------------------------------------------------------------------------------
1 | CHART_REPO := http://jenkins-x-chartmuseum:8080
2 | CURRENT=$(pwd)
3 | NAME := spring-cloud-k8s-minion
4 | OS := $(shell uname)
5 | RELEASE_VERSION := $(shell cat ../../VERSION)
6 |
7 | build: clean
8 | rm -rf requirements.lock
9 | helm dependency build
10 | helm lint
11 |
12 | install: clean build
13 | helm install . --name ${NAME}
14 |
15 | upgrade: clean build
16 | helm upgrade ${NAME} .
17 |
18 | delete:
19 | helm delete --purge ${NAME}
20 |
21 | clean:
22 | rm -rf charts
23 | rm -rf ${NAME}*.tgz
24 |
25 | release: clean
26 | helm dependency build
27 | helm lint
28 | helm init --client-only
29 | helm package .
30 | curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts
31 | rm -rf ${NAME}*.tgz%
32 |
33 | tag:
34 | ifeq ($(OS),Darwin)
35 | sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
36 | sed -i "" -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
37 | else ifeq ($(OS),Linux)
38 | sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
39 | sed -i -e "s/repository: .*/repository: $(DOCKER_REGISTRY)\/salaboy\/spring-cloud-k8s-minion/" values.yaml
40 | sed -i -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
41 | else
42 | echo "platfrom $(OS) not supported to release from"
43 | exit -1
44 | endif
45 | git add --all
46 | git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed
47 | git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)"
48 | git push origin v$(RELEASE_VERSION)
49 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/README.md:
--------------------------------------------------------------------------------
1 | # Java application
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/NOTES.txt:
--------------------------------------------------------------------------------
1 |
2 | Get the application URL by running these commands:
3 |
4 | kubectl get ingress {{ template "fullname" . }}
5 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/_helpers.tpl:
--------------------------------------------------------------------------------
1 | {{/* vim: set filetype=mustache: */}}
2 | {{/*
3 | Expand the name of the chart.
4 | */}}
5 | {{- define "name" -}}
6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7 | {{- end -}}
8 |
9 | {{/*
10 | Create a default fully qualified app name.
11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12 | */}}
13 | {{- define "fullname" -}}
14 | {{- $name := default .Chart.Name .Values.nameOverride -}}
15 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16 | {{- end -}}
17 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/deployment.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: extensions/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: {{ template "fullname" . }}
5 | labels:
6 | draft: {{ default "draft-app" .Values.draft }}
7 | chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8 | spec:
9 | replicas: {{ .Values.replicaCount }}
10 | template:
11 | metadata:
12 | labels:
13 | draft: {{ default "draft-app" .Values.draft }}
14 | app: {{ .Values.service.name }}
15 | {{- if .Values.podAnnotations }}
16 | annotations:
17 | {{ toYaml .Values.podAnnotations | indent 8 }}
18 | {{- end }}
19 | spec:
20 | containers:
21 | - name: {{ .Chart.Name }}
22 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
23 | imagePullPolicy: {{ .Values.image.pullPolicy }}
24 | ports:
25 | - containerPort: {{ .Values.service.internalPort }}
26 | livenessProbe:
27 | httpGet:
28 | path: {{ .Values.probePath }}
29 | port: {{ .Values.service.internalPort }}
30 | initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
31 | periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
32 | successThreshold: {{ .Values.livenessProbe.successThreshold }}
33 | timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
34 | readinessProbe:
35 | httpGet:
36 | path: {{ .Values.probePath }}
37 | port: {{ .Values.service.internalPort }}
38 | periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
39 | successThreshold: {{ .Values.readinessProbe.successThreshold }}
40 | timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
41 | resources:
42 | {{ toYaml .Values.resources | indent 12 }}
43 | terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
44 | serviceAccountName: {{ .Values.service.name }}
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/minion-config-map.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | metadata:
4 | name: {{ .Values.service.name }}
5 | data:
6 | application.properties: |-
7 | minion.type=one-eyed-minion
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/role-bindings.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: rbac.authorization.k8s.io/v1
2 | kind: RoleBinding
3 | metadata:
4 | name: {{ .Chart.Name }}
5 | namespace: {{ .Release.Namespace }}
6 | roleRef:
7 | apiGroup: rbac.authorization.k8s.io
8 | kind: Role
9 | name: {{ .Chart.Name }}
10 | subjects:
11 | - kind: ServiceAccount
12 | name: {{ .Values.service.name }}
13 | namespace: {{ .Release.Namespace }}
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/role.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: rbac.authorization.k8s.io/v1
2 | kind: Role
3 | metadata:
4 | name: {{ .Chart.Name }}
5 | rules:
6 | - apiGroups:
7 | - extensions
8 | resources:
9 | - ingresses
10 | verbs:
11 | - get
12 | - list
13 | - watch
14 | - patch
15 | - create
16 | - update
17 | - delete
18 | - apiGroups:
19 | - ""
20 | resources:
21 | - configmaps
22 | - services
23 | - endpoints
24 | - pods
25 | - configmaps
26 | verbs:
27 | - get
28 | - list
29 | - watch
30 | - patch
31 | - update
32 | - apiGroups:
33 | - apps
34 | resources:
35 | - deployments
36 | verbs:
37 | - get
38 | - list
39 | - watch
40 | - patch
41 | - update
42 | - apiGroups:
43 | - ""
44 | resources:
45 | - routes
46 | verbs:
47 | - get
48 | - list
49 | - watch
50 | - patch
51 | - create
52 | - update
53 | - delete
54 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/service.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | {{- if .Values.service.name }}
5 | name: {{ .Values.service.name }}
6 | {{- else }}
7 | name: {{ template "fullname" . }}
8 | {{- end }}
9 | labels:
10 | chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
11 | {{- if .Values.service.annotations }}
12 | annotations:
13 | {{ toYaml .Values.service.annotations | indent 4 }}
14 | {{- end }}
15 | spec:
16 | type: {{ .Values.service.type }}
17 | ports:
18 | - port: {{ .Values.service.externalPort }}
19 | targetPort: {{ .Values.service.internalPort }}
20 | protocol: TCP
21 | name: {{ .Values.service.name }}
22 | selector:
23 | app: {{ .Values.service.name }}
24 |
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/templates/serviceaccount.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ServiceAccount
3 | metadata:
4 | labels:
5 | app: {{ .Chart.Name }}
6 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
7 | release: "{{ .Release.Name }}"
8 | heritage: "{{ .Release.Service }}"
9 | name: {{ .Values.service.name }}
--------------------------------------------------------------------------------
/charts/spring-cloud-k8s-minion/values.yaml:
--------------------------------------------------------------------------------
1 | # Default values for Maven projects.
2 | # This is a YAML-formatted file.
3 | # Declare variables to be passed into your templates.
4 | replicaCount: 1
5 | image:
6 | repository: draft
7 | tag: dev
8 | pullPolicy: IfNotPresent
9 | service:
10 | name: spring-cloud-k8s-minion
11 | type: ClusterIP
12 | externalPort: 80
13 | internalPort: 8080
14 | annotations:
15 | fabric8.io/expose: "true"
16 | fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx"
17 | resources:
18 | limits:
19 | cpu: 500m
20 | memory: 768Mi
21 | requests:
22 | cpu: 400m
23 | memory: 512Mi
24 | probePath: /actuator/health
25 | livenessProbe:
26 | initialDelaySeconds: 90
27 | periodSeconds: 10
28 | successThreshold: 1
29 | timeoutSeconds: 1
30 | readinessProbe:
31 | periodSeconds: 70
32 | successThreshold: 1
33 | timeoutSeconds: 1
34 | terminationGracePeriodSeconds: 10
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | org.spring.cloud.k8s.examples
6 | minion
7 | 1.0-SNAPSHOT
8 |
9 | jar
10 |
11 | minion
12 | Minion Project
13 |
14 |
15 | 1.8
16 | UTF-8
17 | UTF-8
18 | 2.0.4.RELEASE
19 | Finchley.SR1
20 | 0.3.0.RELEASE
21 | 3.7.0
22 |
23 |
24 |
25 |
26 |
27 | org.springframework.boot
28 | spring-boot-dependencies
29 | ${spring-boot.version}
30 | pom
31 | import
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-dependencies
36 | ${spring-cloud.version}
37 | pom
38 | import
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-kubernetes-dependencies
43 | ${spring.cloud.k8s.version}
44 | pom
45 | import
46 |
47 |
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-kubernetes-discovery
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-starter-kubernetes-config
57 |
58 |
59 | org.springframework.cloud
60 | spring-cloud-starter-netflix-hystrix
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-starter-web
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-starter-actuator
69 |
70 |
71 | org.springframework.boot
72 | spring-boot-starter-test
73 | test
74 |
75 |
76 |
77 |
78 |
79 |
80 | org.apache.maven.plugins
81 | maven-compiler-plugin
82 | ${maven-compiler-plugin.version}
83 |
84 | ${java.version}
85 | ${java.version}
86 | true
87 | true
88 | true
89 |
90 |
91 |
92 | org.springframework.boot
93 | spring-boot-maven-plugin
94 |
95 |
96 |
97 | repackage
98 |
99 |
100 |
101 |
102 |
103 | org.apache.maven.plugins
104 | maven-deploy-plugin
105 | 2.8.2
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | spring-milestones
114 | Spring Milestones
115 | https://repo.spring.io/milestone/
116 |
117 | true
118 |
119 |
120 |
121 | spring-snapshots
122 | Spring Snapshots
123 | https://repo.spring.io/snapshot/
124 |
125 | false
126 |
127 |
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/skaffold.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: skaffold/v1alpha2
2 | kind: Config
3 | build:
4 | tagPolicy:
5 | envTemplate:
6 | template: "{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_HOST}}:{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_PORT}}/salaboy/spring-cloud-k8s-minion:{{.VERSION}}"
7 | artifacts:
8 | - imageName: changeme
9 | workspace: .
10 | docker: {}
11 | local: {}
12 | deploy:
13 | kubectl:
14 | manifests:
15 | profiles:
16 | - name: dev
17 | build:
18 | tagPolicy:
19 | envTemplate:
20 | template: "{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_HOST}}:{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_PORT}}/salaboy/spring-cloud-k8s-minion:{{.DIGEST_HEX}}"
21 | artifacts:
22 | - docker: {}
23 | local: {}
24 | deploy:
25 | helm:
26 | releases:
27 | - name: spring-cloud-k8s-minion
28 | chartPath: charts/spring-cloud-k8s-minion
29 | setValueTemplates:
30 | image.repository: "{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_HOST}}:{{.JENKINS_X_DOCKER_REGISTRY_SERVICE_PORT}}/salaboy/spring-cloud-k8s-minion"
31 | image.tag: "{{.TAG}}"
32 |
--------------------------------------------------------------------------------
/src/main/java/org/minions/demo/Application.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.beans.factory.annotation.Value;
7 | import org.springframework.boot.CommandLineRunner;
8 | import org.springframework.boot.SpringApplication;
9 | import org.springframework.boot.autoconfigure.SpringBootApplication;
10 | import org.springframework.cloud.client.ServiceInstance;
11 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
12 | import org.springframework.cloud.client.discovery.DiscoveryClient;
13 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
14 | import org.springframework.context.annotation.Bean;
15 | import org.springframework.scheduling.annotation.EnableScheduling;
16 | import org.springframework.scheduling.annotation.Scheduled;
17 | import org.springframework.web.client.RestTemplate;
18 |
19 | import java.net.InetAddress;
20 | import java.net.UnknownHostException;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | import static org.minions.demo.BossClientService.FIND_A_BOSS_TASK;
25 |
26 | @SpringBootApplication
27 | @EnableScheduling
28 | @EnableDiscoveryClient
29 | @EnableCircuitBreaker
30 | public class Application implements CommandLineRunner {
31 |
32 | private static final Log log = LogFactory.getLog(Application.class);
33 |
34 | @Autowired
35 | private DiscoveryClient discoveryClient;
36 |
37 | @Autowired
38 | private BossClientService bossClient;
39 |
40 | @Autowired
41 | private MinionConfig minionConfig;
42 |
43 | private String taskAtHand = FIND_A_BOSS_TASK;
44 |
45 | @Bean
46 | RestTemplate restTemplate() {
47 | return new RestTemplate();
48 | }
49 |
50 | @Value("${spring.application.name}")
51 | private String appName;
52 |
53 | public static void main(String[] args) {
54 | SpringApplication.run(Application.class, args);
55 | }
56 |
57 | @Override
58 | public void run(String... args) {
59 | log.info("Minion (" + appName + ":" + minionConfig.getType() + ")Started! ");
60 | }
61 |
62 | /*
63 | * Every 10 seconds look for a boss or keep working on the task at hand
64 | */
65 | @Scheduled(fixedRate = 10000)
66 | public void doSomeWork() throws UnknownHostException {
67 | if (taskAtHand.equals(FIND_A_BOSS_TASK)) {
68 | taskAtHand = findANewBoss();
69 | if (taskAtHand.equals(FIND_A_BOSS_TASK)) {
70 | log.info(">>> NO BOSS FOUND, I will keep looking for one ");
71 | }
72 | }
73 | log.info(">>> Working on " + taskAtHand);
74 | }
75 |
76 | /*
77 | * Every 60 seconds if you are not looking for a Boss, wrap up the task at hand
78 | */
79 | @Scheduled(fixedRate = 60000)
80 | public void finishWork() {
81 | if (!taskAtHand.equals(FIND_A_BOSS_TASK)) {
82 | log.info(">>> Finishing " + taskAtHand);
83 | taskAtHand = FIND_A_BOSS_TASK;
84 | }
85 | }
86 |
87 |
88 | /*
89 | * Find a new boss by filtering the available services based on Metadata
90 | */
91 | private String findANewBoss() throws UnknownHostException {
92 | List services = this.discoveryClient.getServices();
93 |
94 | for (String service : services) {
95 | List instances = this.discoveryClient.getInstances(service);
96 | for (ServiceInstance se : instances) {
97 | Map metadata = se.getMetadata();
98 | String type = metadata.get("type");
99 | if ("boss".equals(type)) {
100 |
101 | String from = appName + "@" + InetAddress.getLocalHost().getHostName();
102 | String url = "http://" + se.getServiceId();
103 | return bossClient.requestMission(url, from);
104 | }
105 | }
106 | }
107 | return FIND_A_BOSS_TASK;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/org/minions/demo/BossClientService.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
4 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
5 | import org.apache.commons.logging.Log;
6 | import org.apache.commons.logging.LogFactory;
7 | import org.springframework.http.HttpMethod;
8 | import org.springframework.http.ResponseEntity;
9 | import org.springframework.stereotype.Service;
10 | import org.springframework.web.client.RestTemplate;
11 |
12 | @Service
13 | public class BossClientService {
14 |
15 | private final RestTemplate restTemplate;
16 |
17 | private static final Log log = LogFactory.getLog(BossClientService.class);
18 |
19 | public static final String FIND_A_BOSS_TASK = "find a new boss";
20 |
21 | public BossClientService(RestTemplate restTemplate) {
22 | this.restTemplate = restTemplate;
23 | }
24 |
25 | @HystrixCommand(fallbackMethod = "getFallbackName", commandProperties = {
26 | @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
27 | })
28 | public String requestMission(String to,
29 | String from) {
30 |
31 | String url = String.format("%s/mission/%s",
32 | to,
33 | from);
34 |
35 | log.info("--- Requesting a task to Boss: " + url);
36 |
37 | return restTemplate.getForObject(url, String.class);
38 | }
39 |
40 | private String getFallbackName(String to,
41 | String from) {
42 | log.error("--- This Boss (" + to + ") not available now, please come back later (Fallback) client:" + from);
43 | return FIND_A_BOSS_TASK;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/minions/demo/Controller.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.net.InetAddress;
5 | import java.net.UnknownHostException;
6 |
7 | import org.apache.commons.logging.Log;
8 | import org.apache.commons.logging.LogFactory;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.beans.factory.annotation.Value;
11 | import org.springframework.cloud.context.config.annotation.RefreshScope;
12 | import org.springframework.web.bind.annotation.RequestMapping;
13 | import org.springframework.web.bind.annotation.ResponseBody;
14 | import org.springframework.web.bind.annotation.RestController;
15 |
16 | import static org.springframework.web.bind.annotation.RequestMethod.GET;
17 |
18 | @RestController
19 | @RefreshScope
20 | public class Controller {
21 |
22 | private static final Log log = LogFactory.getLog(Controller.class);
23 | private final String version = "0.1";
24 |
25 | private MinionsLibrary minionsLibrary;
26 |
27 | @Autowired
28 | private MinionConfig minionConfig;
29 |
30 | public Controller(MinionsLibrary minionsLibrary) {
31 | this.minionsLibrary = minionsLibrary;
32 | }
33 |
34 | @RequestMapping(method = GET)
35 | public String minion() throws UnknownHostException, UnsupportedEncodingException {
36 | StringBuilder stringBuilder = new StringBuilder();
37 | stringBuilder.append("Host: ").append(InetAddress.getLocalHost().getHostName()).append("
");
38 | stringBuilder.append("Minion Type: ").append(minionConfig.getType()).append("
");
39 | stringBuilder.append("IP: ").append(InetAddress.getLocalHost().getHostAddress()).append("
");
40 | stringBuilder.append("Version: ").append(version).append("
");
41 | String minion = minionsLibrary.getMinion(minionConfig.getType());
42 | if (minion != null && !minion.isEmpty()) {
43 | stringBuilder.append(minion);
44 | } else {
45 | stringBuilder.append(" - No Art for this type (" + minionConfig.getType() + ") of minion - ");
46 | }
47 | return stringBuilder.toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/minions/demo/MinionConfig.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import org.springframework.boot.context.properties.ConfigurationProperties;
4 | import org.springframework.context.annotation.Configuration;
5 |
6 | @Configuration
7 | @ConfigurationProperties(prefix = "minion")
8 | public class MinionConfig {
9 |
10 | private String type = "generic-minion";
11 |
12 | public String getType() {
13 | return type;
14 | }
15 |
16 | public void setType(String type) {
17 | this.type = type;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/minions/demo/MinionsLibrary.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import org.springframework.stereotype.Component;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | @Component
9 | public class MinionsLibrary {
10 |
11 | private Map map = new HashMap<>();
12 |
13 | //source of ascii art - http://textart4u.blogspot.co.uk/2013/08/minions-emoticons-text-art-for-facebook.html
14 | public MinionsLibrary(){
15 | map.put("one-eyed-minion"," "+
16 | "──────────▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
" +
17 | "────────█═════════════════█
" +
18 | "──────█═════════════════════█
" +
19 | "─────█════════▄▄▄▄▄▄▄════════█
" +
20 | "────█════════█████████════════█
" +
21 | "────█═══════██▀─────▀██═══════█
" +
22 | "───███████████──█▀█──███████████
" +
23 | "───███████████──▀▀▀──███████████
" +
24 | "────█═══════▀█▄─────▄█▀═══════█
" +
25 | "────█═════════▀█████▀═════════█
" +
26 | "────█═════════════════════════█
" +
27 | "────█══════▀▄▄▄▄▄▄▄▄▄▀════════█
" +
28 | "───▐▓▓▌═════════════════════▐▓▓▌
" +
29 | "───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
" +
30 | "───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
" +
31 | "──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
" +
32 | "──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
" +
33 | "──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
" +
34 | "──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
" +
35 | "──█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
" +
36 | "─▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
" +
37 | "─█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─█████
" +
38 | "─██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─██████
" +
39 | "──▀█▀█──▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌───█▀█▀
" +
40 | "─────────▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
" +
41 | "──────────▐▓▓▓▓▌──▐▓▓▓▓▌
" +
42 | "─────────▄████▀────▀████▄
" +
43 | "─────────▀▀▀▀────────▀▀▀▀
");
44 | map.put("two-eyed-minion"," "+
45 | "──────────▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
" +
46 | "────────█═════════════════█
" +
47 | "──────█═════════════════════█
" +
48 | "─────█═══▄▄▄▄▄▄▄═══▄▄▄▄▄▄▄═══█
" +
49 | "────█═══█████████═█████████═══█
" +
50 | "────█══██▀────▀█████▀────▀██══█
" +
51 | "───██████──█▀█──███──█▀█──██████
" +
52 | "───██████──▀▀▀──███──▀▀▀──██████
" +
53 | "────█══▀█▄────▄██─██▄────▄█▀══█
" +
54 | "────█════▀█████▀───▀█████▀════█
" +
55 | "────█═════════════════════════█
" +
56 | "────█══════▀▄▄▄▄▄▄▄▄▄▄▄═══════█
" +
57 | "───▐▓▓▌═════════════════════▐▓▓▌
" +
58 | "───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
" +
59 | "───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
" +
60 | "──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
" +
61 | "──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
" +
62 | "──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
" +
63 | "──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
" +
64 | "──█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
" +
65 | "─▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
" +
66 | "─█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─█████
" +
67 | "─██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─██████
" +
68 | "──▀█▀█──▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌───█▀█▀
" +
69 | "─────────▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
" +
70 | "──────────▐▓▓▓▓▌──▐▓▓▓▓▌
" +
71 | "─────────▄████▀────▀████▄
" +
72 | "─────────▀▀▀▀────────▀▀▀▀
");
73 | map.put("sad-minion"," "+
74 | "──────────▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
" +
75 | "────────█═════════════════█
" +
76 | "──────█═════════════════════█
" +
77 | "─────█═══▄▄▄▄▄▄▄═══▄▄▄▄▄▄▄═══█
" +
78 | "────█═══█████████═█████████═══█
" +
79 | "────█══██▀────▀█████▀────▀██══█
" +
80 | "───██████──█▀█──███──█▀█──██████
" +
81 | "───██████──▀▀▀──███──▀▀▀──██████
" +
82 | "────█══▀█▄────▄██─██▄────▄█▀══█
" +
83 | "────█════▀█████▀───▀█████▀════█
" +
84 | "────█═════════════════════════█
" +
85 | "────█═════════▄▀▀▀▄═══════════█
" +
86 | "───▐▓▓▌══════▀═════▀════════▐▓▓▌
" +
87 | "───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
" +
88 | "───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
" +
89 | "──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
" +
90 | "──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
" +
91 | "──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
" +
92 | "──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
" +
93 | "──█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
" +
94 | "─▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
" +
95 | "─█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─█████
" +
96 | "─██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─██████
" +
97 | "──▀█▀█──▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌───█▀█▀
" +
98 | "─────────▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
" +
99 | "──────────▐▓▓▓▓▌──▐▓▓▓▓▌
" +
100 | "─────────▄████▀────▀████▄
" +
101 | "─────────▀▀▀▀────────▀▀▀▀
");
102 | map.put("happy-minion"," "+
103 | "────────────▀▄───█───▄▀
" +
104 | "───────────▄▄▄█▄▄█▄▄█▄▄▄
" +
105 | "────────▄▀▀═════════════▀▀▄
" +
106 | "───────█═══════════════════█
" +
107 | "──────█═════════════════════█
" +
108 | "─────█═══▄▄▄▄▄▄▄═══▄▄▄▄▄▄▄═══█
" +
109 | "────█═══█████████═█████████═══█
" +
110 | "────█══██▀────▀█████▀────▀██══█
" +
111 | "───██████─█▀█───███─█▀█───██████
" +
112 | "───██████─▀▀▀───███─▀▀▀───██████
" +
113 | "────█══▀█▄────▄██─██▄────▄█▀══█
" +
114 | "────█════▀█████▀───▀█████▀════█
" +
115 | "────█═════════════════════════█
" +
116 | "────█═════════════════════════█
" +
117 | "────█═══════█▀█▀█▀█▀█▀█═══════█
" +
118 | "────█═══════▀▄───────▄▀═══════█
" +
119 | "───▐▓▓▌═══════▀▄█▄█▄▀═══════▐▓▓▌
" +
120 | "───▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
" +
121 | "───█══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
" +
122 | "──█══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
" +
123 | "──█══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
" +
124 | "──█══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
" +
125 | "──█══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
" +
126 | "──█══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
" +
127 | "─▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
" +
128 | "─█████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─█████
" +
129 | "─██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌─██████
" +
130 | "──▀█▀█──▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌───█▀█▀
" +
131 | "─────────▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
" +
132 | "──────────▐▓▓▓▓▌──▐▓▓▓▓▌
" +
133 | "─────────▄████▀────▀████▄
" +
134 | "─────────▀▀▀▀────────▀▀▀▀
");
135 | }
136 |
137 | public String getMinion(String name){
138 | return map.get(name);
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=spring-cloud-k8s-minion
2 | server.port=8080
3 |
4 | spring.cloud.kubernetes.reload.enabled=true
5 | #spring.cloud.kubernetes.reload.strategy=restart_context
6 | #spring.cloud.kubernetes.reload.mode=polling
7 |
8 | management.endpoint.health.enabled=true
9 | management.endpoint.info.enabled=true
10 | management.endpoint.restart.enabled=true
11 |
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/test/java/org/minions/demo/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package org.minions.demo;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | @RunWith(SpringRunner.class)
9 | @SpringBootTest
10 | public class ApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------