-
下載 Windows 版本安裝檔案[1],並執行
-
下載[2]並安裝 kubectl,我簡單加了一個自定義的 bin 檔案夾,用於存放環境變數
-
開啟 CMD,鍵入 minikube start, 一旦 minikube 啟動,叢集安裝,就可以使用 kubectl cluster-info 來確認
FROM node:8.5.0
WORKDIR /usr/src/node-service
# Install node packages
COPY package.json ./
RUN npm install
# Copy the source for the app
COPY . .
# Run the app
CMD ["npm", "start"]
# Expose container ports
EXPOSE 3000
docker build -t fullbit/node-service .
docker run -p 3000:3000 -d fullbit/node-service
docker login
docker push fullbit/node-service:latest
-
下載[4]安裝檔案
-
壓並將 helm.exe 放到與 kubectl 相同的 bin 檔案夾中
-
開啟 CMD,執行 helm 確認安裝
-
在 CMD 中執行 helm init 命令在 minikube 叢集上安裝 Tiller
values.yaml
replicaCount: 1
image:
repository: fullbit/node-service
tag: latest
pullPolicy: IfNotPresent
service:
type: NodePort
port: 3000
nodePort: 30001
ingress:
enabled: false
annotations: {}
path: /
hosts:
- chart-example.local
tls: []
resources: {}
nodeSelector: {}
tolerations: []
affinity: {} }}}
接下來需要使用 service 埠值更新部署模板:
{{{templates/deployment.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "node-service.fullname" . }}
labels:
app: {{ template "node-service.name" . }}
chart: {{ template "node-service.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "node-service.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "node-service.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: {{ template "node-service.fullname" . }}
labels:
app: {{ template "node-service.name" . }}
chart: {{ template "node-service.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
nodePort: {{ .Values.service.nodePort }}
protocol: TCP
name: http
selector:
app: {{ template "node-service.name" . }}
release: {{ .Release.Name }}
kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}"
-
https://github.com/kubernetes/minikube/releases/download/v0.25.0/minikube-installer.exe
-
https://storage.googleapis.com/kubernetes-release/release/v1.9.0/bin/windows/amd64/kubectl.exe
-
https://hub.docker.com/r/fullbit/node-service/
-
https://storage.googleapis.com/kubernetes-helm/helm-v2.8.1-windows-amd64.zip
-
https://kubernetes.io/docs/concepts/services-networking/service/