# 설치 가이드 #
## 명령어와 설정 방법이 있습니다 ##
### 순서대로 진행 해주세요 ###

1. kubectl create ns cicd
2. ingress 혹은 infra 노드에 라벨 설정하기
- kubectl label nodes 노드이름 node=infra
3. vi values.yaml
4. values.yaml에서 필요한 부분 수정하기
- namespace, storageClass, domain, core, externalURL, hostName, hostRepo, hosts 등등
5. helm install -n cicd cicd .
6. k logs -f -n cicd 로 postgresql watch로 보면서 sonar 유저 생성되는지 확인
7. 전체 다 파드가 running 확인
8. argocd, jenkins, scm-manager, nexus, sonarqube 브라우저 접속 후 비밀번호 변경해주기
- argocd 초기 비밀번호 명령어
- kubectl get secret -n cicd argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 --decode && echo
- jenkins는 -> jenkins 관리 -> security -> Security Realm -> db 사용으로 저장 후 계정 만들기
- scm-manager는 kubectl logs -n cicd cicd-scm-manager-랜덤-랜덤 -> token 찾기
- nexus는 -> kubectl exec -it -n cicd cicd-nexus-repository-manager-랜덤-랜덤 cat /nexus-data/admin.password && echo
- sonarqube는 admin/admin
9. plugins 파일 및 pv 덮어쓰기
- jenkins 플러그인 폴더
- cp -r 젠킨스 플러그인/* 젠킨스의 nfs 혹은 roo-ceph 폴더 안쪽 plugins 폴더로 덮어쓰기
- 사내에서 다운받은 파일 파드에 넣어주기 ( jenkins.yaml, Configuration as Code 여기서 다운 )
- kubectl cp jenkins.yaml -n cicd cicd-jenkins-0:/tmp
- chown -R ubuntu:ubuntu 혹은 사용자 권한으로 변경하기
- jenkins 브라우저로 접속해서 주소 뒤에 /restart 넣고 재시작하기
- cp -r scm-manager/* scm-manager의 nfs 혹은 roo-ceph 폴더로 덮어쓰기
- chown -R ubuntu:ubuntu 혹은 사용자 권한으로 변경하기
- kubectl delete po -n cicd cicd-scm-manager-랜덤-랜덤 --force
- jenkins관리 -> Configuration as Code -> 빈칸에 /tmp/jenkins.yaml 입력 후 탭키
- apply 누르기
- viola-pass 설치 문서 보면서 필요한 부분만 수정하기
10. 작업 전체 완료 후 워커노드에 라벨 설정하기
- kubectl label nodes 노드이름 node=worker
=======================================================================================
여기는 TLS 적용 시에만 사용

* tls는 values-tls.yaml 사용
* 기존에 있던 values.yaml에서 필요한 부분을 values-tls.yaml에 수정

- 고객사에서 인증서를 받으면 아래와 같이 명령어로 k8s에 secret 생성 해주세요.

kubectl create secret tls harbor-tls --cert=server.crt --key=server.key -n cicd
kubectl create secret tls jenkins-tls --cert=server.crt --key=server.key -n cicd
kubectl create secret tls nexus-tls --cert=server.crt --key=server.key -n cicd
kubectl create secret tls scm-manager-tls --cert=server.crt --key=server.key -n cicd
kubectl create secret tls sonarqube-tls --cert=server.crt --key=server.key -n cicd

- values-tls.yaml에서 미들웨어 도메인들 고객사에 맞게 변경 후

helm upgrade -n cicd cicd -f values-tls.yaml . ( . 넣어주세요 )

- Ingress 443 PORTS 추가 확인
kubectl get ing -n cicd

- nerdctl 설정 변경

vi /etc/containerd/certs.d/harbor.hrfco.cloud/hosts.toml

# http를 https로 변경
server = "https://harbor.hrfco.cloud"
[host."https://harbor.hrfco.cloud"]
  capabilities = ["pull","resolve","push"]
  skip_verify = true

nerdctl login 후 푸시, 풀 테스트