---
# create NS
apiVersion: v1
kind: Namespace
metadata:
▄▄name: theknowledge-services
---
apiVersion: apps/v1
kind: Deployment
metadata:
▄▄name: portainer
▄▄namespace: portainer
spec:
▄▄replicas: 1
▄▄selector:
▄▄▄▄matchLabels:
▄▄▄▄▄▄▄app: portainer
▄▄template:
▄▄▄▄metadata:
▄▄▄▄▄▄labels:
▄▄▄▄▄▄▄▄app: portainer
▄▄▄▄spec:
▄▄▄▄▄▄containers:
▄▄▄▄▄▄▄▄- name: portainer
▄▄▄▄▄▄▄▄▄▄image: portainer/portainer-ce
/
├── dockerfile
├── app/ # Python application
│ ├── main.py
│ ├── router.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── web.py
│ │ └── webhook.py
│ ├── services/
│ │ ├── __init__.py
│ │ ├── mail_api_check.py
│ │ ├── messanger_api_check.py
│ │ ├── status.py
│ │ ├── send_msg.py
│ │ └── send_mail.py
│ ├── configs/
│ │ ├── config.yaml
│ │ └── target.yaml
│ ├── authentication/
│ │ ├── __init__.py
│ │ └── authentication.py
│ ├── core/
│ │ ├── __init__.py
│ │ └── refresh.py
│ ├── templates/
│ │ ├── index.html
│ │ ├── login.html
│ │ └── base.html
│ ├── static/
│ │ ├── css/
│ │ │ └── style.css
│ │ └── js/
│ │ └── main.js
│ └── requirements.txt
├── charts/
│ ├── chart.yaml
│ └── values.yaml
├── config/
│ ├── core-site.xml
│ ├── hdfs-site.xml
│ └── other-config.yaml
├── files/
│ ├── entrypoint.sh
│ ├── app/ # java application
│ │ ├── application-runtime.bin
│ │ └── libs/
│ │ └── trino-connector-jdbc.jar
│ └── other-config.yaml
├── k8s/
│ ├── configmap.yaml
│ ├── deployment.yaml
│ ├── ingress.yaml
│ └── service.yaml
└── README.md
---
# create NS
apiVersion: v1
kind: Namespace
metadata:
name: theknowledge-services
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: portainer
namespace: portainer
spec:
replicas: 1
selector:
matchLabels:
app: portainer
template:
metadata:
labels:
app: portainer
spec:
containers:
- name: portainer
image: portainer/portainer-ce:lts
args:
- -H
- unix:///var/run/docker.sock
ports:
- containerPort: 9000
- containerPort: 8000
volumeMounts:
- name: portainer-data
mountPath: /data
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: portainer-data
persistentVolumeClaim:
claimName: portainer-pvc
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: Socket
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: portainer-pvc
namespace: portainer
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: portainer
namespace: portainer
spec:
type: NodePort
selector:
app: portainer
ports:
- name: http
port: 9000
targetPort: 9000
nodePort: 30002 # 외부 접속 포트
- name: edge
port: 8000
targetPort: 8000
# Command:
# kubectl create namespace $NAMESPACE
# kubectl delete -f yaml 수행 시 namespace가 포함 돼있으면 namespace까지 삭제되나?
| 종류 | 설명 |
| deployment | 단순 어플리케이션 배포. 특정한 상태, 확인 등이 필요 없는 어플리케이션 Replicaset 지정 가능 |
| statefulset | 클러스터링이 필요한 어플리케이션. 파드마다 각각 고유한 네트워크, PV를 마운트 한다. Pod들은 숫자로 관리되고 재시작시에도 고유한 ID, 네트워크를 유지한다. NiFi 클러스터, DBMS 클러스터 등과 같이 각 노드가 구분돼야 하는 어플리케이션 |
| replicaset | deployment+복제 파드. 일반적으로 replicaset으로 파드를 생성하지 않고 deployment에서 replicaset을 지정한다. |
| daemonset | 어플리케이션 기준이 아닌 Kubernetes node를 기준으로 배포.(전체 노드 혹은 특정 노드) 노드 모니터링을 위한 export 등을 배포할 때 사용한다. |
# portainer 배포 예시
apiVersion: apps/v1
kind: Deployment
metadata:
name: portainer
namespace: portainer
spec:
replicas: 1 # Replica 수 지정.
selector:
matchLabels:
app: portainer
template:
metadata:
labels:
app: portainer
spec:
containers:
- name: portainer
image: portainer/portainer-ce:lts
# IfNotPresent: 동일한 태그의 Image가 있을 경우 Pull하지 않음 // Aways: 매번 Image Pull // Never: 미리 다운로드 되어있는 Image 사용
imagePullPolicy: IfNoPresent # policy key가없는 경우 Image의 Tag가 Latest인경우 기본값은 Always. 특정 Tag가 지정된 경우 IfNotPresent가 기본 값이다.
args:
- -H
- unix:///var/run/docker.sock
ports:
- containerPort: 9000
- containerPort: 8000
volumeMounts:
- name: portainer-data
mountPath: /data
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: portainer-data
persistentVolumeClaim:
claimName: portainer-pvc
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: Socket