因為HAPI FHIR Server打包成image的方式與先前打包的方式不同,因此K8s的deployment.yaml也會與先前的deployment.yaml不一樣。
在遇到不知道怎麼寫deployment.yaml的時候,可以看看image的內部描述,ENTRYPOINT=command,CMD=args。
先下指令查看image的內部描述
docker inspect ${image_name}
再照著內容修改deployment.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hapi-fhir-server
namespace: default
labels:
app: hapi-fhir-server
spec:
selector:
matchLabels:
app: hapi-fhir-server
strategy:
type: Recreate
replicas: 1
template:
metadata:
name: hapi-fhir-server
labels:
app: hapi-fhir-server
spec:
nodeName: node1
containers:
- name: hapi-fhir-server
image: hapi-fhir-jpaserver-starter-hapi-fhir-jpaserver-start
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
command: [ "java",
"--class-path",
"/app/main.war",
"-Dloader.path=main.war!/WEB-INF/classes/,main.war!/WEB-INF/,/app/extra-classes",
"org.springframework.boot.loader.PropertiesLauncher"
]
---
apiVersion: v1
kind: Service
metadata:
name: hapi-fhir-server
namespace: default
labels:
app: hapi-fhir-server
spec:
type: NodePort
selector:
app: hapi-fhir-server
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
nodePort: ${nodeport}
創建完yaml檔後執行指令即可將服務上到K8s。
K8s指令
$ kubectl create -f hapi-fhir-server.yaml
或是
$ kubectl apply -f hapi-fhir-server.yaml