|
|
(2 intermediate revisions by the same user not shown) |
Line 54: |
Line 54: |
| apk --update add minio-client inetutils-telnet | | apk --update add minio-client inetutils-telnet |
|
| |
|
| echo -n password: ;\
| | mcli alias set k8s_gitlab_aa http://minio.minio:9000 Tnen3kCv71osfJKkhcIP rxMU6fWayQD6no1p1LO7orBmxNMtbKuyHITpflBJ |
| read -s MINIO_SERVER_ROOT_PASSWORD;\
| | mcli admin info k8s_gitlab_aa |
| export MINIO_SERVER_ROOT_PASSWORD;\
| |
| export MINIO_SERVER_ROOT_USER=admin;\
| |
| export MINIO_SERVER_HOST=minio.k8s.local;echo
| |
| | |
| mcli ping --error-count 5 minio.minio
| |
| mcli ping --count 5 minio.minio
| |
| | |
| telnet minio.minio 9000
| |
| telnet minio.minio 9001
| |
| </syntaxhighlight>
| |
| | |
| ==Apply==
| |
| ===Apply » Minikube » USER===
| |
| {|
| |
| |-
| |
| | colspan="3" |
| |
| ----
| |
| |-
| |
| | valign="top" |
| |
| '''PV » Manual'''
| |
| ----
| |
| | valign="top" |
| |
| '''PV » Dynamic'''
| |
| ----
| |
| | valign="top" |
| |
| '''Service & Deployment'''
| |
| ----
| |
| |-
| |
| | valign="top" |
| |
| <syntaxhighlight lang="yaml" highlight="8,13-14,23,29">
| |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| apiVersion: v1
| |
| kind: PersistentVolume
| |
| metadata:
| |
| name: swiss-knife-${USER}-pv
| |
| spec:
| |
| storageClassName: standard
| |
| capacity:
| |
| storage: 10Gi
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| hostPath:
| |
| path: /tmp/hostpath-provisioner/swiss-knife/swiss-knife-${USER}-pvc
| |
| ---
| |
| apiVersion: v1
| |
| kind: PersistentVolumeClaim
| |
| metadata:
| |
| labels:
| |
| app.kubernetes.io/name: swiss-knife-${USER}
| |
| name: swiss-knife-${USER}-pvc
| |
| spec:
| |
| storageClassName: standard
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| resources:
| |
| requests:
| |
| storage: 10Gi
| |
| volumeName: swiss-knife-${USER}-pv
| |
| YML
| |
| </syntaxhighlight>
| |
| | |
| | valign="top" |
| |
| <syntaxhighlight lang="yaml" highlight="8,13-14,23,29">
| |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| ---
| |
| apiVersion: v1
| |
| kind: PersistentVolumeClaim
| |
| metadata:
| |
| labels:
| |
| app.kubernetes.io/name: swiss-knife-${USER}
| |
| name: swiss-knife-${USER}-pvc
| |
| spec:
| |
| storageClassName: standard
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| resources:
| |
| requests:
| |
| storage: 10Gi
| |
| | |
| YML
| |
| </syntaxhighlight>
| |
| | |
| | valign="top" rowspan="2" |
| |
| <syntaxhighlight lang="yaml" line>
| |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| apiVersion: v1
| |
| kind: Service
| |
| metadata:
| |
| name: swiss-knife-${USER}
| |
| spec:
| |
| ports:
| |
| - port: 80
| |
| selector:
| |
| app: swiss-knife-${USER}
| |
| clusterIP: None
| |
| ---
| |
| apiVersion: apps/v1
| |
| kind: Deployment
| |
| metadata:
| |
| name: swiss-knife-${USER}
| |
| spec:
| |
| selector:
| |
| matchLabels:
| |
| app: swiss-knife-${USER}
| |
| replicas: 1
| |
| template:
| |
| metadata:
| |
| labels:
| |
| app: swiss-knife-${USER}
| |
| spec:
| |
| containers:
| |
| - name: nginx
| |
| image: nginx:1.27-alpine
| |
| ports:
| |
| - containerPort: 80
| |
| volumeMounts:
| |
| - mountPath: /opt/swiss-knife/${USER}
| |
| name: ${USER}-data
| |
| volumes:
| |
| - name: ${USER}-data
| |
| persistentVolumeClaim:
| |
| claimName: swiss-knife-${USER}-pvc
| |
| restartPolicy: Always
| |
| YML
| |
| </syntaxhighlight>
| |
| | |
| |-
| |
| | colspan="2" |
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -c nginx -- sh
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -- sh
| |
| </syntaxhighlight>
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| kubectl -n swiss-knife port-forward svc/swiss-knife-${USER} 1980:80
| |
| kubectl -n swiss-knife port-forward svc/swiss-knife-${USER} :80
| |
| </syntaxhighlight>
| |
| | |
| |-
| |
| | colspan="3" |
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| # copy dump into pod
| |
| SWISS_KNIFE_POD=$(kubectl -n swiss-knife get pods -l app=swiss-knife-${USER} -ojson|jq -r '.items[0].metadata.name')
| |
| kubectl -n swiss-knife cp ./gitlab_sdlc-20240820-T1622-ZP0800.sql.gz ${SWISS_KNIFE_POD}:/opt/swiss-knife/${USER}
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -- ls -lah /opt/swiss-knife/${USER}
| |
| | |
| # install apk packages
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -- sh
| |
| apk --update add postgresql-client inetutils-telnet
| |
| | |
| # import psql dump
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -- sh
| |
| echo -n password: ;read -s PGPASSWORD;export PGPASSWORD;echo
| |
| gunzip -c /opt/swiss-knife/${USER}/./gitlab_sdlc-20240820-T1622-ZP0800.sql.gz|psql -Ugitlab gitlab
| |
| psql -d gitlab -U gitlab
| |
| </syntaxhighlight>
| |
| | |
| |-
| |
| | colspan="3" |
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| kubectl -n swiss-knife delete deploy swiss-knife-${USER}
| |
| kubectl -n swiss-knife delete svc swiss-knife-${USER}
| |
| kubectl -n swiss-knife delete pvc swiss-knife-${USER}-pvc
| |
| kubectl delete pv swiss-knife-${USER}-pv
| |
| </syntaxhighlight>
| |
| | |
| |}
| |
| | |
| ===Apply » EKS » USER===
| |
| {|
| |
| |-
| |
| | colspan="3" |
| |
| ----
| |
| |-
| |
| | valign="top" |
| |
| '''PV » Manual'''
| |
| ----
| |
| | valign="top" |
| |
| '''PV » Dynamic'''
| |
| ----
| |
| | valign="top" |
| |
| '''Service & Deployment'''
| |
| ----
| |
| |-
| |
| | valign="top" |
| |
| <syntaxhighlight lang="yaml" highlight="8,13-16,25,31">
| |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| apiVersion: v1
| |
| kind: PersistentVolume
| |
| metadata:
| |
| name: swiss-knife-${USER}-pv
| |
| spec:
| |
| storageClassName: "gp2"
| |
| capacity:
| |
| storage: 10Gi
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| awsElasticBlockStore:
| |
| fsType: ext4
| |
| volumeID: aws://ap-southeast-1/${EBS_VOLUME_ID}
| |
| persistentVolumeReclaimPolicy: Retain
| |
| ---
| |
| apiVersion: v1
| |
| kind: PersistentVolumeClaim
| |
| metadata:
| |
| labels:
| |
| app.kubernetes.io/name: swiss-knife-${USER}
| |
| name: swiss-knife-${USER}-pvc
| |
| spec:
| |
| storageClassName: "gp2"
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| resources:
| |
| requests:
| |
| storage: 10Gi
| |
| volumeName: swiss-knife-${USER}-pv
| |
| YML
| |
| </syntaxhighlight>
| |
| | |
| | valign="top" |
| |
| <syntaxhighlight lang="yaml" highlight="8,13-16,25,31">
| |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|
| |
|
| | mcli alias set k8s_gitlab_ab http://minio.minio:9000 FfG564tLdSlgaM2t0ig0 FEbThROKMZ06Feddr1SUMk85g4wRM5NZnVVrS24V |
| | mcli admin info k8s_gitlab_ab |
|
| |
|
| | mcli alias set s3_host_ab http://s3.host.k8s.local O2PLF0Pznp12HNbT9FbJ YIISq1Srxf9gv24fxkryN5ilQDg8P5wxJXt1qgle |
| | mcli admin info s3_host_ab |
|
| |
|
| ---
| | mcli alias set s3_host_aa http://s3.host.k8s.local 6zXMWye9rOjKgpka pHKjpqiXK4RLpvdyX7qYuwbIk5KAkKa6 |
| apiVersion: v1
| | mcli admin info s3_host_aa |
| kind: PersistentVolumeClaim
| |
| metadata:
| |
| labels:
| |
| app.kubernetes.io/name: swiss-knife-${USER}
| |
| name: swiss-knife-${USER}-pvc
| |
| spec:
| |
| storageClassName: "gp2"
| |
| accessModes:
| |
| - ReadWriteOnce
| |
| resources:
| |
| requests:
| |
| storage: 10Gi
| |
| volumeName: swiss-knife-${USER}-pv
| |
| YML
| |
| </syntaxhighlight>
| |
|
| |
|
| | valign="top" rowspan="2"|
| | mcli alias set k8s_admin http://minio.minio:9000 admin sadaqah! |
| <syntaxhighlight lang="yaml" highlight="28-29" line>
| | mcli admin info k8s_admin |
| cat << YML | kubectl -n swiss-knife apply -f -
| |
| ---
| |
| apiVersion: v1
| |
| kind: Service
| |
| metadata:
| |
| name: swiss-knife-${USER}
| |
| spec:
| |
| ports:
| |
| - port: 80
| |
| selector:
| |
| app: swiss-knife-${USER}
| |
| clusterIP: None
| |
| ---
| |
| apiVersion: apps/v1
| |
| kind: Deployment
| |
| metadata:
| |
| name: swiss-knife-${USER}
| |
| spec:
| |
| selector:
| |
| matchLabels:
| |
| app: swiss-knife-${USER}
| |
| replicas: 1
| |
| template:
| |
| metadata:
| |
| labels:
| |
| app: swiss-knife-${USER}
| |
| spec:
| |
| nodeSelector:
| |
| topology.kubernetes.io/zone: ap-southeast-1a
| |
| containers:
| |
| - name: nginx
| |
| image: nginx:1.27-alpine
| |
| ports:
| |
| - containerPort: 80
| |
| volumeMounts:
| |
| - mountPath: /opt/swiss-knife/${USER}
| |
| name: ${USER}-data
| |
| volumes:
| |
| - name: ${USER}-data
| |
| persistentVolumeClaim:
| |
| claimName: swiss-knife-${USER}-pvc
| |
| restartPolicy: Always
| |
| YML
| |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
| |-
| |
| | colspan="2" |
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -c nginx -- sh
| |
| kubectl -n swiss-knife exec -it svc/swiss-knife-${USER} -- sh
| |
| </syntaxhighlight>
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| kubectl -n swiss-knife port-forward svc/swiss-knife-${USER} 1980:80
| |
| kubectl -n swiss-knife port-forward svc/swiss-knife-${USER} :80
| |
| </syntaxhighlight>
| |
|
| |
| |-
| |
| | colspan="3" |
| |
| ----
| |
| <syntaxhighlight lang="bash">
| |
| # aws » ec2 » ebs » volume » name: sdlc-eks-swiss-knife-${USER}-data
| |
| kubectl -n swiss-knife delete deploy swiss-knife-${USER}
| |
| kubectl -n swiss-knife delete svc swiss-knife-${USER}
| |
| kubectl -n swiss-knife delete pvc swiss-knife-${USER}-pvc
| |
| kubectl delete pv swiss-knife-${USER}-pv
| |
| </syntaxhighlight>
| |
|
| |
| |}
| |
|
| |
|
| ==Playground== | | ==Playground== |
Line 477: |
Line 144: |
|
| |
|
| | valign="top" | | | | valign="top" | |
|
| |
| * [https://stackoverflow.com/questions/31870222 K8s » <code>kubectl run</code> » <code>sleep infinity</code>]
| |
| * [https://stackoverflow.com/questions/71043168/ K8s » Attache a Volume to Pod Container] | | * [https://stackoverflow.com/questions/71043168/ K8s » Attache a Volume to Pod Container] |
| * [https://stackoverflow.com/questions/23929235/ Bash » Multi-line String With Indentation] | | * [https://stackoverflow.com/questions/23929235/ Bash » Multi-line String With Indentation] |
Line 485: |
Line 150: |
| * [[K8s/Swiss Knife|K8s » Swiss Knife]] | | * [[K8s/Swiss Knife|K8s » Swiss Knife]] |
| * [[K8s/Ingress|K8s » Ingress]] | | * [[K8s/Ingress|K8s » Ingress]] |
| | * [[K8s/Service|K8s » Service]] |
| * [[MinIO]] | | * [[MinIO]] |
| * [[CIDR]] | | * [[CIDR]] |
Line 490: |
Line 156: |
|
| |
|
| | valign="top" | | | | valign="top" | |
| | * [https://stackoverflow.com/questions/31870222 K8s » <code>kubectl run</code> » <code>sleep infinity</code>] |
|
| |
|
| |} | | |} |