├── README.md
├── chart
│ ├── Chart.yaml # Chart基本資訊
│ ├── charts # 依賴
│ ├── templates # Kubernetes模板
│ │ ├── NOTES.txt
│ │ ├── _helpers.tpl
│ │ ├── deployment.yaml
│ │ ├── ingress.yaml
│ │ └── service.yaml
│ └── values.yaml # 變數
├── Dockerfile # Dockerfile定義
├── entrypoint.sh # 容器的entrypoint.sh檔案
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src # 應用原始碼
│ └── main
│ └── java
│ └── hello
│ ├── Application.java
│ └── HelloController.java
├── Dockerfile # Dockerfile定義
├── entrypoint.sh # 容器的entrypoint.sh檔案
# Build
FROM maven:3.5.0-jdk-8-alpine AS builder
ADD ./pom.xml pom.xml
ADD ./src src/
RUN mvn clean package
# Package
FROM java:8
COPY --from=builder target/gs-spring-boot-0.1.0.jar gs-spring-boot.jar
RUN bash -c 'touch /gs-spring-boot.jar'
ADD entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
#!/usr/bin/env bash
ACTIVE_PROFILE=${PROFILE:=default}
java -Xmx1024m -Djava.security.egd=file:/dev/./urandom -jar gs-spring-boot.jar --spring.profiles.active=${ACTIVE_PROFILE} $@
$ docker build -t yunlzheng/spring-app . # 修改為自己的映象倉庫
Sending build context to Docker daemon 16.38MB
Step 1/10 : FROM maven:3.5.0-jdk-8-alpine AS builder
---> 67d11473f554
......
Successfully built e332622092ce
Successfully tagged yunlzheng/spring-app:latest
docker push yunlzheng/spring-app # 修改為自己的映象倉庫
├── chart
│ ├── Chart.yaml # Chart基本資訊
│ ├── charts # 依賴
│ ├── templates # Kubernetes模板
│ │ ├── NOTES.txt
│ │ ├── _helpers.tpl
│ │ ├── deployment.yaml
│ │ ├── ingress.yaml
│ │ └── service.yaml
│ └── values.yaml # 變數
$ helm create chart
Creating chart
apiVersion: v1
appVersion: "1.0"
description: A Spring Boot Application
name: chart
version: 0.1.0
replicaCount: 1
image:
repository: yunlzheng/spring-app #修改為自己的映象
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 8080 #容器對映的埠
ingress:
enabled: true # 開啟叢集ingress
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- spring-example.local
tls: []
# deployment.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "chart.fullname" . }}
labels:
app: {{ template "chart.name" . }}
chart: {{ template "chart.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "chart.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "chart.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
$ cd chart
$ helm lint
==> Linting .
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, no failures
$ cd chart
$ helm install .
# 省略其它輸出
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
womping-sparrow-spring-app ClusterIP 172.19.11.41 <none> 8080/TCP 1s
NOTES:
1. Get the application URL by running these commands:
http://spring-example.local/
$ cd ..
$ helm package chart
Successfully packaged chart and saved it to: /Users/yunlong/workspace/project-samples/containerization-spring-with-helm/chart-0.1.0.tgz
$ helm package chart --version 0.0.2
Successfully packaged chart and saved it to: /workspace/tmp/spring-sample/chart-0.0.2.tgz
helm repo add play-helm https://repomanage.rdc.aliyun.com/helm_repositories/26125-play-helm --username=kHKvnX --password=WsCH7zuHH2
$ helm plugin install https://github.com/chartmuseum/helm-push
Downloading and installing helm-push v0.7.1 ...
https://github.com/chartmuseum/helm-push/releases/download/v0.7.1/helm-push_0.7.1_darwin_amd64.tar.gz
Installed plugin: push
$ helm push chart-0.1.0.tgz play-helm
Pushing chart-0.1.0.tgz to play-helm...
Done.
$ helm update
...Successfully got an update from the "play-helm" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈
$ helm search play-helm
NAME CHART VERSION APP VERSION DESCRIPTION
play-helm/chart 0.1.0 1.0 A Spring Boot Application
$ helm install play-helm/chart
$ helm push chart-0.1.0.tgz play-helm --version=0.2.0
Pushing chart-0.2.0.tgz to play-helm...
Done.
$ helm push chart play-helm --version=0.3.0
Pushing chart-0.1.0.tgz to play-helm...
Done.
$ helm push chart https://repomanage.rdc.aliyun.com/helm_repositories/26125-play-helm --username=kHKvnX --password=WsCH7zuHH2
Pushing chart-0.1.0.tgz to https://repomanage.rdc.aliyun.com/helm_repositories/26125-play-helm...
Done.
-
https://github.com/yunlzheng/project-samples/tree/master/containerization-spring-with-helm