-
테크톤(컨테이너 이미지 기반 작업 배포)
step : 명령어 수행되는 부분(작업지시) -> 의존성 있어 task안에서 동작해야함
task: hello.yaml같은게 보통 task 하나 가짐- Tekton 설정
// Tekton Operator를 설치 kubectl apply -f https://storage.googleapis.com/tekton-releases/operator/previous/v0.70.2/release.yaml // Tekton CLI 다운로드 wget https://github.com/tektoncd/cli/releases/download/v0.32.0/tkn_0.32.0_Linux_x86_64.tar.gz // Tekton Hub에서 제공하는 buildah와 kubernetes-actions 작업을 설치 kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/buildah/0.7/raw //> task.tekton.dev/buildah created kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/kubernetes-actions/0.2/raw //> task.tekton.dev/kubernetes-actions created // Tekton 작업 목록 확인 tkn task list ================================================= //> -bash: tkn: command not found 해당 오류 발생 // GPT발 해결법 // Tekton CLI 바이너리를 다운로드 curl -LO https://github.com/tektoncd/cli/releases/download/v0.30.1/tkn_0.30.1_Linux_x86_64.tar.gz // 다운로드한 파일을 추출 tar xvzf tkn_0.30.1_Linux_x86_64.tar.gz // tkn 바이너리를 /usr/local/bin 디렉토리로 이동 sudo mv tkn /usr/local/bin/ // tkn 명령어의 실행 권한을 확인 chmod +x /usr/local/bin/tkn ================================================= // 다시 Tekton 작업 목록 확인 tkn task list //> NAME DESCRIPTION AGE //> buildah Buildah task builds... 7 minutes ago //> kubernetes-actions This task is the ge... 7 minutes ago // hello.yaml 작업 생성 nano hello.yaml ------------------------------------------------ apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: hello spec: steps: - image: quay.io/centos/centos command: - /bin/bash - -c - echo "Hello World" ------------------------------------------------ // 작업 생성 kubectl create -f hello.yaml //> task.tekton.dev/hello created // 모든 작업을 나열 kubectl get tasks //> NAME AGE //> buildah 8m3s //> hello 5s //> kubernetes-actions 7m59s // Tekton CLI를 사용하여 클러스터에 존재하는 모든 작업을 나열 tkn task list //> NAME DESCRIPTION AGE //> buildah Buildah task builds... 8 minutes ago //> hello 15 seconds ago //> kubernetes-actions This task is the ge... 8 minutes ago // hello 작업을 실행하고 로그를 출력 tkn task start hello --showlog //> TaskRun started: hello-run-782d4 //> Waiting for logs to be available... //> [unnamed-0] Hello World
- Tekton 사용법
kubectl get pod //> NAME READY STATUS RESTARTS AGE //> hello-run-jrrpd-pod 0/1 Completed 0 80s tkn task start hello //> TaskRun started: hello-run-7mntw //> //> In order to track the TaskRun progress run: //> tkn taskrun logs hello-run-7mntw -f -n default // 위에서 알려주는 명령어 입력 tkn taskrun logs hello-run-7mntw -f -n default kubectl get pod -n tekton-pipelines //> NAME READY STATUS RESTARTS AGE //> tekton-chains-controller-5f98467cc7-9ct7l 1/1 Running 1 18h //> tekton-dashboard-7c67cfd4c4-pcxlr 1/1 Running 1 18h //> tekton-events-controller-554b957dff-s7scj 1/1 Running 1 18h //> tekton-operator-proxy-webhook-7ffc879584-hqgkv 1/1 Running 1 18h //> tekton-pipelines-controller-7d6486fd5b-q76bv 1/1 Running 1 18h //> tekton-pipelines-remote-resolvers-74c6d4f86b-4n2pt 1/1 Running 1 18h //> tekton-pipelines-webhook-5dd4457658-h9lk6 1/1 Running 1 18h //> tekton-triggers-controller-68dc754b4d-4nvbj 1/1 Running 1 18h //> tekton-triggers-core-interceptors-b76d7ddfc-hcdc6 1/1 Running 1 18h //> tekton-triggers-webhook-78cf9d7669-p97vp 1/1 Running 1 18h // task 수정 nano hello2.yaml ----------------------------------------------------------------------------------------- // name과 steps에 echo 변경 apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: hello-2 spec: steps: - image: quay.io/centos/centos command: - /bin/bash - -c - echo "Hello World2" ----------------------------------------------------------------------------------------- kubectl apply -f hello2.yaml //> task.tekton.dev/hello-2 created tkn task list //> NAME DESCRIPTION AGE //> buildah Buildah task builds... 38 minutes ago //> hello 37 minutes ago //> hello-2 9 seconds ago kubectl get task //> NAME AGE //> buildah 38m //> hello 37m //> hello-2 28s //> kubernetes-actions 38m tkn task describe hello-2 //> Name: hello-2 //> Namespace: default //> //> 🦶 Steps //> //> ∙ unnamed-0 nano hello2.yaml ----------------------------------------------------------------------------------------- apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: hello-2 spec: steps: - name: welcome-message image: quay.io/centos/centos command: - /bin/bash - -c - echo "Hello World2" ----------------------------------------------------------------------------------------- tkn task describe hello-2 //> Name: hello-2 //> Namespace: default //> //> 🦶 Steps //> //> ∙ welcome-message tkn task start hello-2 //> TaskRun started: hello-2-run-69b5v //> //> In order to track the TaskRun progress run: //> tkn taskrun logs hello-2-run-69b5v -f -n default // 작업 확인법 1번 -> pod에 추가됨 kubectl get pod //> NAME READY STATUS RESTARTS AGE //> hello-2-run-69b5v-pod 0/1 Completed 0 44s // 작업 확인법 2번 tkn taskrun list //> NAME STARTED DURATION STATUS //> hello-2-run-69b5v 1 minute ago 5s Succeeded //> hello-run-7mntw 43 minutes ago 5s Succeeded //> hello-run-jrrpd 46 minutes ago 23s Succeeded // 작업 확인법 3번 -> 로그 조회 tkn taskrun logs hello-2-run-69b5v -f -n default //> [welcome-message] Hello World2
- 깃 서버 만들기
dnf install wget -y wget https://raw.githubusercontent.com/drabo/gogs/master/gogs.yaml nano gogs.yaml --------------------------------------------------------------------------- // 아래 부분 주석 해제 --- apiVersion: v1 kind: PersistentVolume metadata: name: gogs-pv namespace: gogs labels: type: local spec: accessModes: - ReadWriteOnce capacity: storage: 2Gi hostPath: path: /mnt/data/gogs // 다음 내용은 아래에 추가 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: gogs-ingress namespace: gogs annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: gogs.local http: paths: - path: / pathType: Prefix backend: service: name: gogs-svc port: number: 18080 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: gogs-ingress namespace: gogs annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: gogs.local http: paths: - path: / pathType: Prefix backend: service: name: gogs-svc port: number: 18080 --------------------------------------------------------------------------- kubectl apply -f gogs.yaml kubectl get pods -ngogs //> NAME READY STATUS RESTARTS AGE //> gogs-75f989f5df-wz4d8 1/1 Running 0 16s kubectl get svc -ngogs //> NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE //> gogs-svc NodePort 10.90.141.226 <none> 10022:30022/TCP,18080:30080/TCP 26s // 음... kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.1/deploy/static/provider/cloud/deploy.yaml
- window
// 관리자 권한으로 cmd 실행 notepad hosts // 메모장에서 다음 내용 추가 - 앞의 ip는 eth0에서 가져오기 172.21.203.25 gogs.local
- 포드만 서버에서 아래 파일 찾기
mkdir php-ip cd php-ip git init cp ../ip-v* ../Containerfile-php . git add . git commit -m "hehehehe" git remote add origin http://gogs.local:30080/gogs/php-ip.git git push -u origin master
'CICD' 카테고리의 다른 글
쿠버네티스 용어 정리 (0) 2024.06.14 레지스트리 서버 만들기 (0) 2024.06.13 pod, deploment, replicaset (0) 2024.06.11 pod, application container (0) 2024.06.11 쿠버네티스 (0) 2024.06.10