> brew install kubectl
or
> brew install kubernetes-cli
설치 스크린샷
# 참고 - 제 계정에 추가된 설정 alias k=kubectl
alias kns="kubectl config set-context --current --namespace"
complete -F __start_kubectl k
# 개인상황에 맞게 만들면 돼요
> mkdir -p ~/WhaTap/BASE
# 개인상황에 맞게 만들면 돼요
> mkdir -p ~/WhaTap/BASE/yaml
❯ cat pv-BASE.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-local
labels:
type: local
spec:
storageClassName: local
capacity:
storage: 100Gi
accessModes:
- ReadWritspanany
hostPath:
path: "/Users/mkpark/WhaTap/BASE"
> k apply -f pv-BASE.yaml
> k create ns tomcat8-test
> kns tomcat8-test
> cat pvc-BASE.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-local
spec:
storageClassName: local
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
> k apply -f pvc-BASE.yaml
❯ k create deploy tomcat8 --image=arm64v8/openjdk:8 --dry-run=client -oyaml > deploy-tomcat8.yaml
❯ cat deploy-tomcat8.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: tomcat8
name: tomcat8
spec:
replicas: 1
selector:
matchLabels:
app: tomcat8
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: tomcat8
spec:
containers:
- image: arm64v8/openjdk:8
name: openjdk
resources: {}
status: {}
volumeMounts:
- mountPath: "/data"
name: pvc-volume
volumes:
- name: pvc-volume
persistentVolumeClaim:
claimName: pvc-local
resources:
requests:
memory: "64Mi"
cpu: "100m"
limits:
memory: "384Mi"
cpu: "500m"
# 개인상황에 맞게 솔루션을 넣으시면 돼요
> cd ~/WhaTap/BASE/
> curl -LO https://downloads.apache.org/tomcat/tomcat-8/v8.5.63/bin/apache-tomcat-8.5.63.tar.gz
> tar -zxf apache-tomcat-8.5.63.tar.gz
=> apache-tomcat-8.5.63/bin/catalina.sh 의 501/511 라인의 백그라운드 실행(&) 부분을 지워 주세요.
command: ["/bin/sh", "-c"]
args:
- echo starting;
cd /data/apache-tomcat-8.5.63/bin;
./startup.sh;
echo done;
> k apply -f deploy-tomcat8.yaml
# 기본 yaml 만들기
> k expose deployment tomcat8 --name=svc-tomcat8 --type=NodePort --port=8080
--target-port=8080 --dry-run=client -oyaml > svc-tomcat8.yaml
# 다음 내용 추가
nodePort: 32000
접근을 편하게 하기 위해 NodePort 추가 (30000 ~ 32000 사이 지정)
# 서비스 생성
> k apply -f svc-tomcat8.yaml
> k get no -owide
http://192.168.65.4:32000