준비. 저장소 생성

프로그램소스가 저장될 공간을 bitbucket에 생성합니다.

처음이므로 먼저 프로젝트를 생성합니다.

웹UI 로그인 -> 상단 Projects -> Create project 클릭

 

- Poject name : sy-project

- Project key : SYP (대문자로 자동생성됩니다.)

Create project 클릭합니다.

 

repository를 생성합니다. Create repository 클릭

 

- Name : sy-repo

- Default branch name : main

Create repository 클릭합니다.

 

아래 화면이 나오면 성공입니다.

 

준비. 저장소로 push 

테스트로 파일하나 생성하고 저장소로 git push 해봅니다.

PS C:\Users\ky945> cd SYprj
 
PS C:\Users\ky945\SYprj> notepad sytest.txt

this is CI/CD test file


PS C:\Users\ky945\SYprj> ls

    Directory: C:\Users\ky945\SYprj

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---        2025-04-20  오후 5:00             23 sytest.txt

PS C:\Users\ky945\SYprj> git init
Initialized empty Git repository in C:/Users/ky945/SYprj/.git/

PS C:\Users\ky945\SYprj> git add --all

PS C:\Users\ky945\SYprj> git commit -m "Initial Commit SY"
[master (root-commit) 7e99962] Initial Commit SY
 1 file changed, 1 insertion(+)
 create mode 100644 sytest.txt

PS C:\Users\ky945\SYprj> git remote add origin https://bitb.sytech.store/scm/syp/sy-repo.git

PS C:\Users\ky945\SYprj> git push -u origin HEAD:main
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
git: 'credential-manager-core' is not a git command. See 'git --help'.
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 240 bytes | 240.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://bitb.sytech.store/scm/syp/sy-repo.git
 * [new branch]      HEAD -> main
branch 'master' set up to track 'origin/main'.

 

참고. 진행중에 아래 팝업창이 나오면 "Password/Token" 선택하고 username 과 password 입력합니다.

 

준비. 서버생성

빌드는 Bamboo 로컬에서 가능하고, 원격서버에도 가능합니다. 여기서는 로컬에서 빌드하는걸로 하겠습니다.

배포는 원격서버에 합니다. 도커 컨테이너로 배포 대상서버(ubuntu)를 설치합니다. 

PS C:\Users\ky945\SYubuntu> notepad Dockerfile

# Dockerfile
FROM ubuntu:latest

# 원격에서 ssh 접속할 수 있게 ssh서버를 설치합니다.
RUN apt-get update && \
    apt-get install -y openssh-server && \
    mkdir /var/run/sshd

# root 비밀번호 설정 (예: root:root)
RUN echo 'root:root' | chpasswd

# SSH 접속 시 필요한 설정
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
    sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

PS C:\Users\ky945\SYubuntu> docker build -t syubuntu .
# 도커 이미지를 빌드합니다.

PS C:\Users\ky945\SYubuntu> docker run -d -p 22:22 --name sy-ubuntu syubuntu
ea42aedd7c456efe56702fdc68ac662e84fb156951b29ed13527ff6671395b3e
# 컨테이너로 기동합니다.

PS C:\Users\ky945\SYubuntu> ssh root@localhost
The authenticity of host 'localhost (::1)' can't be established.
ED25519 key fingerprint is SHA256:7tPmV3s741qVSZvEfDmpqKV/FiCeYL7gmZI1pWqyJno.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
root@localhost's password:
root@ea42aedd7c45:~#
# 컨테이너로 ssh접속이 정상입니다.

 

준비를 끝내고 plan 생성을 시작합니다.

 

- Project name : sy-bam-project

- Project key : SYB (자동입력됨)

- Project description : sy bamboo project

- Plan name : sy-bam-plan

- Plan key : SYB (자동입력됨)

- Plan description : sy bamboo plan

Create 클릭!

 

- Repository host : Link new repository -> Bitbucket DC/Server 선택

"Link Bamboo to Bitbucket Server" 클릭!

 

Create link 클릭!

 

- Application URL : https://bitb.sytech.store (bitbucket 설치한 URL주소입력)

continue 클릭!

 

주의! 그전에 bitbucket에 로그인해 있어야합니다. 그렇지않으면 Link 생성이 안됩니다. 버그인듯...

bitbucket가 서로 통신이 가능한것을 확인합니다. continue 클릭!

 

bitbucket 사이트로 redirect 되고, bamboo 와 연결이 정상인것을 확인합니다. continue 클릭!

 

bamboo 주소로 redirect 됩니다. Status가 "CONNECTED" 보이면 성공입니다.

 

설치진행 페이지로 다 돌아옵니다.

- Display name : sy-bam-display (적당한 이름 입력)

"Login & approve" 클릭 !

 

Bamboo에서 접근하는걸 허락합니다. Allow 클릭!

 

주의! bitbucket에서 ssh 서비스를 외부로 노출해야합니다. bamboo가 빌드에 필요한 소스저장소를 ssh로 접근합니다. 다음처럼 설정하고 적용합니다.

PS C:\Users\ky945\SYk8s> notepad bitbucket-values.yaml

bitbucket:
  sshService:
    enabled: true    # false 를 true로 변경합니다.
    port: 7999       # 기본포트 7999로 입력합니다.
    
PS C:\Users\ky945\SYk8s> helm upgrade --install sy-bitb syrepo-bitbucket/bitbucket `
--namespace syns-bitb `
--set fullnameOverride=sybitb `
-f bitbucket-values.yaml
# bitbucket-values.yaml 내용을 변경하고, 적용합니다.

PS C:\Users\ky945\SYk8s> k get svc -n syns-bitb
NAME          TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                    AGE
sybitb        ClusterIP      10.99.51.156    <none>        80/TCP,7999/TCP,5701/TCP   2d19h
sybitb-ssh    LoadBalancer   10.102.95.203   localhost     7999:32542/TCP             2d
# sybitb-ssh 서비스가 생성되었고, 7999 포트로 외부노출이 된것이 확인됩니다.

 

계속진행합니다.

- Repository : sy-project / sy-repo 선택

- Branch : main 선택

"Save and continue" 클릭!

 

'쿠버네티스 환경' 카테고리의 다른 글

Bamboo 설치  (0) 2025.04.13
Bitbucket 설치  (0) 2025.04.09
인그레스 컨트롤러 설치  (0) 2025.04.05
helm 설치  (0) 2025.04.05
공인인증서 만들기  (0) 2025.04.04

bitbucket data center 설치완료하고 간단하게 CI/CD 테스트를 하려고합니다.

bitbucket 개발사에서 나온 Bamboo를 설치해서 이용하겠습니다.

 

준비.도메인주소 등록

설치된 bamboo 를 접근하기 위한 도메인주소를 정하고, 가비아 사이트에가서 등록합니다.

bamb.sytech.store 로 등록하겠습니다.

 

준비. 네임스페이스 생성

bamboo가 설치될 namespace를 마련합니다.

PS C:\Users\ky945\SYk8s> k create namespace syns-bamb
namespace/syns-bamb created

 

준비. 시크릿 생성

bamb.sytech.store 도메인으로 https 접속을 위해 인증서 값을 secret 으로 생성합니다.

*.sytech.store 도메인에 공인인증서가 있는 로컬PC 디렉토리 위치로 이동합니다.

다음 명령어를 실행합니다.

PS C:\Users\ky945\sytech.store.ssl> ls

    Directory: C:\Users\ky945\sytech.store.ssl

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---        2025-04-04  오후 8:33           2036 sytech.store.crt
-a---        2025-04-04  오후 8:33           2494 sytech.store.key
-a---        2025-04-04  오후 8:33           3866 sytech.store.pem

PS C:\Users\ky945\sytech.store.ssl> k create secret tls sy-bamb-tls `
>> --cert=sytech.store.crt `
>> --key=sytech.store.key `
>> -n syns-bamb
secret/sy-bamb-tls created

 

추가로 secret 하나더 생성합니다.

이후에 bitbucket 과 Bamboo 간에 Application link 생성시 서로에 도메인 인증서가 등록되야합니다.

저는 와일드카드 인증서라서 그대로 사용하겠습니다.

주의! key 파일이 담기지않게 생성해야합니다. 그렇지않으면 pod 기동시 keytool 명령어에서 인증서 에러가 납니다.

PS C:\Users\ky945\sytech.store.ssl> k create secret generic sy-bamb-fullcrt `
--from-file=sytech.store.pem -n syns-bamb
# TLS타입이 아닌 generic 타입으로 생성합니다. key파일까지 들어가면 안됩니다.
# chain인증서까지 있는 pem파일로 생성했습니다. sytech.store.crt 이파일도 될지는 테스트 못해봤습니다.

PS C:\Users\ky945\SYk8s> k get secret -n syns-bamb
NAME                               TYPE                 DATA   AGE
sy-bamb-fullcrt                    Opaque               1      3h43m
sy-bamb-tls                        kubernetes.io/tls    2      6d16h
sypostgre                          Opaque               1      4d6h
# 생성된거를 확인합니다.

 

준비. 영구스토리지 생성

간단하게 설치하고 테스트하기위한 목적이므로 StorageClass는 hostpath를 사용합니다.

bamboo에서는 local-home 과 shared-home 2개의 스토리지가 필요합니다.

로컬PC에 2개 용도로 디렉토리를 생성합니다.

PS C:\Users\ky945\SYbamb> ls

    Directory: C:\Users\ky945\SYbamb

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----        2025-04-13  오후 8:08                local-home    # 로컬용 PV 디렉토리
d----        2025-04-14  오후 9:04                shared-home   # 공유용 PV 디렉토리

 

로컬용 스토리지볼륨을 생성합니다.

PS C:\Users\ky945\SYbamb> cd ../SYk8s

PS C:\Users\ky945\SYk8s> notepad sy-bamb-local-home.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: sy-bamb-local-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/run/desktop/mnt/host/c/Users/ky945/SYbamb/local-home"
    type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: sy-bamb-local-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  resources:
    requests:
      storage: 10Gi
      
PS C:\Users\ky945\SYk8s> k apply -f sy-bamb-local-home.yaml -n syns-bamb
persistentvolume/sy-bamb-local-pv created
persistentvolumeclaim/sy-bamb-local-pvc created
# syns-bamb 네임스페이스에 생성이 완료되었습니다.

 

공유용 스토리지볼륨을 생성합니다.

PS C:\Users\ky945\SYk8s> notepad sy-bamb-shared-home.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: sy-bamb-shared-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/run/desktop/mnt/host/c/Users/ky945/SYbamb/shared-home"
    type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: sy-bamb-shared-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  resources:
    requests:
      storage: 10Gi

PS C:\Users\ky945\SYk8s> k apply -f sy-bamb-shared-home.yaml -n syns-bamb
persistentvolume/sy-bamb-shared-pv created
persistentvolumeclaim/sy-bamb-shared-pvc created
# syns-bamb 네임스페이스에 생성을 성공하였습니다.

 

준비. database 설치

bamboo에서는 별도에 databse를 사용할것을 권고하고 있습니다.

간단하게 설치할수있는 PostgreSQL로 설치하겠습니다.

PS C:\Users\ky945> helm repo add syrepo-bitnami https://charts.bitnami.com/bitnami
PS C:\Users\ky945> helm repo update syrepo-bitnami
PS C:\Users\ky945> helm install sy-postgre syrepo-bitnami/postgresql `
>> --set auth.postgresPassword=2qkrckdqo `
>> --set primary.persistence.enabled=false `
>> --namespace syns-bamb `
>> --set fullnameOverride=sypostgre
NAME: sy-postgre
LAST DEPLOYED: Wed Apr 16 06:18:05 2025
NAMESPACE: syns-bamb
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql
CHART VERSION: 16.6.3
APP VERSION: 17.4.0

Did you know there are enterprise versions of the Bitnami catalog? For enhanced secure software supply chain features, unlimited pulls from Docker, LTS support, or application customization, see Bitnami Premium or Tanzu Application Catalog. See https://www.arrow.com/globalecs/na/vendors/bitnami for more information.

** Please be patient while the chart is being deployed **

PostgreSQL can be accessed via port 5432 on the following DNS names from within your cluster:

    sypostgre.syns-bamb.svc.cluster.local - Read/Write connection

To get the password for "postgres" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace syns-bamb sypostgre -o jsonpath="{.data.postgres-password}" | base64 -d)

To connect to your database run the following command:

    kubectl run sypostgre-client --rm --tty -i --restart='Never' --namespace syns-bamb --image docker.io/bitnami/postgresql:17.4.0-debian-12-r15 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
      --command -- psql --host sypostgre -U postgres -d postgres -p 5432

    > NOTE: If you access the container using bash, make sure that you execute "/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash" in order to avoid the error "psql: local user with ID 1001} does not exist"

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace syns-bamb svc/sypostgre 5432:5432 &
    PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5432

WARNING: The configured password will be ignored on new installation in case when previous PostgreSQL release was deleted through the helm command. In that case, old PVC will have an old password, and setting it through helm won't take effect. Deleting persistent volumes (PVs) will solve the issue.

WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
  - primary.resources
  - readReplicas.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

 

repository 추가

모든준비가 끝났으면 atlassian에 repository를 추가하고, update를 합니다.

PS C:\Users\ky945\SYk8s> helm repo add syrepo-bamboo https://atlassian.github.io/data-center-helm-charts
"syrepo-bamboo" has been added to your repositories

PS C:\Users\ky945\SYk8s> helm repo update syrepo-bamboo
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "syrepo-bamboo" chart repository
Update Complete. ⎈Happy Helming!⎈

 

설정값 적용

설처전에 ingress 와 영구스토리지에 대한 설정을 적용해야합니다.

bamboo에 values을 가져옵니다.

PS C:\Users\ky945\SYk8s> helm show values syrepo-bamboo/bamboo > bamboo-values.yaml

 

yaml파일에 volumes , ingress , bamboo 부분을 설정합니다.

PS C:\Users\ky945\SYk8s> notepad bamboo-values.yaml

volumes:
  localHome:
    persistentVolumeClaim:
      create: false                    # 자동생성되는것을 취소합니다. 기본값.
    customVolume:                      # {} 이부분 삭제하세요
      persistentVolumeClaim:
        claimName: sy-bamb-local-pvc   # 사전에 생성한 로컬용 pvc를 지정합니다.
  sharedHome:
    persistentVolumeClaim:
      create: false                    # 자동생성되는것을 취소합니다. 기본값.
    customVolume:                      # {} 이부분 삭제하세요
      persistentVolumeClaim:
        claimName: sy-bamb-local-pvc   # 사전에 생성한 공유용 pvc를 지정합니다.
        
ingress:
  create: true                     # ingress를 생성합니다.
  className: "nginx"               # ingress contoller는 nginx 사용합니다. 기본값.
  nginx: true                    
  host: bamb.sytech.store          # bamboo 접속 주소
  path: /                         
  tlsSecretName: sy-bamb-tls       # https 통신을 위한 TLS secret을 지정합니다.

bamboo:
  additionalCertificates:
    secretName: sy-bamb-fullcrt    # 추후 bamboo 와 bitbucket 간에 Application link 생성을 위해 필요합니다.

 

설치실행

PS C:\Users\ky945\SYk8s> helm install sy-bamb syrepo-bamboo/bamboo `
>> --namespace syns-bamb `
>> --set fullnameOverride=sybamb `
>> -f bamboo-values.yaml
NAME: sy-bamb
LAST DEPLOYED: Tue Apr 15 06:18:02 2025
NAMESPACE: syns-bamb
STATUS: deployed
REVISION: 1
NOTES:
Thank you for installing Bamboo.

Your release is named sy-bamb, and resides in namespace syns-bamb.

Please run sanity tests against the release to verify it's healthy:

  $ helm test sy-bamb -n syns-bamb

If the Kubernetes resources in the release are still starting up, then the tests may fail, so it
is advisable to wait for the tests to pass before continuing.

To see the custom values you used for this release:

  $ helm get values sy-bamb -n syns-bamb

Bamboo service URL: https://bamb.sytech.store/

For further documentation, see https://atlassian.github.io/data-center-helm-charts/

 

helm으로 설치가 완료되었습니다.

PC 웹브라우저에서  https://bamb.sytech.store 접속합니다.

라이센스 입력을 해야합니다. 하단에 "Generate a Bamboo Data Center license" 클릭합니다.

 

새창이 열리고 다음을 입력 과 선택합니다.

- 조직 : SYcompany 

- 인스턴스는 : '아직 설치되지 않음' 

"라이선스 생성" 클릭합니다.

 

생성된 라이선스 키를 복사합니다.

 

다시 원래 설치페이지로 돌아와서 복사한 라이선스키를 붙여넣습니다.

 

준비과정에서 간단히 설치한 PostgreSQL 을 선택합니다.

 

DB접속정보를 입력합니다.

Database URL : jdbc:postgresql://sypostgre.syns-bamb.svc.cluster.local:5432/postgres   
# PostgreSQL 설치시에 기본생성된 postgres DB를 사용합니다.

User name : postgres  
# PostgreSQL 설치시에 기본생성된 계정을 사용합니다.

Password : **** 
# PostgreSQL 설치시에 설정한 비밀번호를 입력합니다.

 

admin계정을 생성합니다.

 

설치를 성공했습니다.

 

'쿠버네티스 환경' 카테고리의 다른 글

CI/CD 테스트2  (0) 2025.04.17
Bitbucket 설치  (0) 2025.04.09
인그레스 컨트롤러 설치  (0) 2025.04.05
helm 설치  (0) 2025.04.05
공인인증서 만들기  (0) 2025.04.04

gitlab 같은 프로그램소스 저장소 기능이 있는 S/W 입니다.

 

준비.도메인주소 등록

설치된 bitbucket 을 접근하기 위한 도메인주소를 정하고, 가비아 사이트에가서 등록합니다.

bitb.sytech.store 로 등록하겠습니다.

 

준비. 네임스페이스 생성

bitbucket이 설치될 namespace를 마련합니다.

PS C:\Users\ky945\sytech.store.ssl> k create namespace syns-bitb
namespace/syns-bitb created

PS C:\Users\ky945\sytech.store.ssl> k get namespace -A
NAME              STATUS   AGE
default           Active   33h
kube-node-lease   Active   33h
kube-public       Active   33h
kube-system       Active   33h
syns-bitb         Active   2s   # <---- 생성되었습니다.
syns-ingress      Active   32h
syns-nginx        Active   32h

PS C:\Users\ky945\sytech.store.ssl>

 

준비. 시크릿 생성

bitb.sytech.store 도메인으로 https 접속을 위해 인증서 값을 secret 으로 생성합니다.

*.sytech.store 도메인에 공인인증서가 있는 로컬PC 디렉토리 위치로 이동합니다.

다음 명령어를 실행합니다.

PS C:\Users\ky945> cd sytech.store.ssl

PS C:\Users\ky945\sytech.store.ssl> ls

    Directory: C:\Users\ky945\sytech.store.ssl

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---        2025-04-04  오후 8:33           2036 sytech.store.crt
-a---        2025-04-04  오후 8:33           2494 sytech.store.key
-a---        2025-04-04  오후 8:33           3866 sytech.store.pem
# crt 와 key 파일이 있어야 합니다.

PS C:\Users\ky945\sytech.store.ssl> k create secret tls sy-bitb-tls `
--cert=sytech.store.crt `
--key=sytech.store.key `
-n syns-bitb
secret/sy-bitb-tls created   # 생성이 성공하였습니다.

PS C:\Users\ky945\sytech.store.ssl> k get secret -n syns-bitb
NAME          TYPE                DATA   AGE
sy-bitb-tls   kubernetes.io/tls   2      7m11s

# syns-bitb 네임스페이스에 secret이 생성되었습니다.

 

추가로 secret 하나더 생성합니다.

이후에 bitbucket 과 Bamboo 간에 Application link 생성시 서로에 도메인 인증서가 등록되야합니다.

저는 와일드카드 인증서라서 그대로 사용하겠습니다.

주의! key 파일이 담기지않게 생성해야합니다. 그렇지않으면 pod 기동시 keytool 명령어에서 인증서 에러가 납니다.

PS C:\Users\ky945\sytech.store.ssl> k create secret generic sy-bitb-fullcrt `
--from-file=sytech.store.pem -n syns-bitb
# TLS타입이 아닌 generic 타입으로 생성합니다. key파일까지 들어가면 안됩니다.
# chain인증서까지 있는 pem파일로 생성했습니다. sytech.store.crt 이파일도 될지는 테스트 못해봤습니다.

PS C:\Users\ky945\sytech.store.ssl> k get secret -n syns-bitb
NAME                            TYPE                 DATA   AGE
sy-bitb-fullcrt                 Opaque               1      11s
sy-bitb-tls                     kubernetes.io/tls    2      10d
# 생성된거를 확인합니다.

 

준비. 영구스토리지 생성

간단하게 설치하고 테스트하기위한 목적이므로 StorageClass는 hostpath를 사용합니다.

PV 와 PVC 생성 yaml 파일을 만듭니다.

PS C:\Users\ky945> cd SYk8s
PS C:\Users\ky945\SYk8s> notepad sy-bitb-pv-pvc.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: sy-bitb-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/run/desktop/mnt/host/c/Users/ky945/SYbitb/data"
# 로컬PC에 C:\Users\ky945\SYbitb\data 를 미리생성해야 합니다.
# /run/desktop/mnt/host/ 뒤에 로컬PC 경로를 붙이는 방법으로 path를 입력합니다.
    type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: sy-bitb-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: hostpath
  resources:
    requests:
      storage: 10Gi
      
PS C:\Users\ky945\SYk8s> k apply -f sy-bitb-pv-pvc.yaml -n syns-bitb
persistentvolume/sy-bitb-pv created
persistentvolumeclaim/sy-bitb-pvc created
# pvc는 syns-bitb 네임스페이스에 생성이 됩니다.

 

repository 추가

모든준비가 끝났으면 bitbucket에 repository를 추가하고, update를 합니다.

PS C:\Users\ky945\SYk8s> helm repo add syrepo-bitbucket https://atlassian.github.io/data-center-helm-charts
"syrepo-bitbucket" has been added to your repositories

PS C:\Users\ky945\SYk8s> helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "syrepo-ingress-nginx" chart repository
...Successfully got an update from the "syrepo-bitbucket" chart repository
...Successfully got an update from the "syrepo-bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

 

설정값 적용

설처전에 ingress 와 영구스토리지에 대한 설정을 적용해야합니다.

bitbucket에 values을 가져옵니다.

PS C:\Users\ky945\SYk8s> helm show values syrepo-bitbucket/bitbucket > bitbucket-values.yaml

PS C:\Users\ky945\SYk8s> ls

    Directory: C:\Users\ky945\SYk8s

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---        2025-04-12  오전 6:07            525 sy-bitb-pv-pvc.yaml
-a---        2025-04-12  오전 6:27          57792 bitbucket-values.yaml

 

bitbucket-values.yaml 파일을 열어서 다음값을 설정합니다.

PS C:\Users\ky945\SYk8s> notepad bitbucket-values.yaml

# 211라인 volumes 내용이 있습니다.
# 값들을 찾아서 변경합니다.
volumes:
  localHome:
    persistentVolumeClaim:
      create: false              # 자동생성되는것을 취소합니다. 기본값.
    customVolume:                # {} 이부분 삭제하세요
      persistentVolumeClaim:
        claimName: sy-bitb-pvc   # 사전에 생성한 pvc를 지정합니다.
  
# 434라인부터 ingress 내용이 있습니다.
# 값들을 찾아서 변경합니다.
ingress:
  create: true                   # ingress를 생성합니다.
  className: "nginx"             # ingress contoller는 nginx 사용합니다. 기본값.
  nginx: true                    
  host: bitb.sytech.store        # bitbucket 접속 주소
  path: /                         
  tlsSecretName: sy-bitb-tls     # https 통신을 위한 TLS secret을 지정합니다.
  
# 1267라인에 secretName 내용이 있습니다.
bitbucket:
  additionalCertificates:        # 1158라인에 있는거와 혼동하시면 안됩니다.
    secretName: sy-bitb-fullcrt  # 추후 bamboo 와 bitbucket 간에 Application link 생성을 위해 필요합니다.

주의! secretName 값이 2곳에 있습니다. bitbucket -> mesh -> additionalCertificates -> secretName: 여기 아닙니다.

 

설치실행

PS C:\Users\ky945\SYk8s> helm install sy-bitb syrepo-bitbucket/bitbucket `
>> --namespace syns-bitb `            # bitbucket 네임스페이스에 설치합니다.
>> --set fullnameOverride=sybitb `    # 이름이 길게 나오지않게 지정합니다.
>> -f bitbucket-values.yaml           # 설정한 값으로 적용합니다.
NAME: sy-bitb
LAST DEPLOYED: Sat Apr 12 08:01:19 2025
NAMESPACE: syns-bitb
STATUS: deployed
REVISION: 1
NOTES:
Thank you for installing Bitbucket.

Your release is named sy-bitb, and resides in namespace syns-bitb.

Please run sanity tests against the release to verify it's healthy:

  $ helm test sy-bitb -n syns-bitb

If the Kubernetes resources in the release are still starting up, then the tests may fail, so it
is advisable to wait for the tests to pass before continuing.

To see the custom values you used for this release:

  $ helm get values sy-bitb -n syns-bitb

Bitbucket service URL: https://bitb.sytech.store/



For further documentation, see https://atlassian.github.io/data-center-helm-charts/

# 위 내용으로 나오면 설치는 성공입니다.

 

접속확인

https://bitb.sytech.store 접속합니다. 아래 내용으로 보이면 성공입니다.

Language는 English, Database는 internal로 선택하고 Next를 클릭합니다.

운영환경에서는 별도에 Databse를 사용하라고 합니다.

 

Licensing and settings

- Application title : SYBitbucket 입력

- License key : I need an evaluation license 선택

Generate license

- I have an account  선택 (계정이 없는분은 Create an account 선택합니다.)

 

로그인하면 다음 페이지가 보여집니다.

- 조직 : SYcompany 입력합니다.

- 인스턴스는 "아직 설치되지 않음" 선택합니다.

- "라이선스 생성" 클릭합니다.

 

확인 클릭

 

다시 원래화면으로 돌아왔습니다.

License key 값이 자동으로 들어가 있습니다. Next 클릭.

 

오류메시지가 나옵니다. 

무시하시고 "Retry Operation" 클릭합니다.

관리자 정보를 입력합니다.

"Go to Bitbucket"을 클릭합니다.

 

앞에서 입력한 Username 과 Password 입력후 "Log in" 클릭합니다.

 

아래 화면이 나오면 설치는 성공입니다.

 

'쿠버네티스 환경' 카테고리의 다른 글

CI/CD 테스트2  (0) 2025.04.17
Bamboo 설치  (0) 2025.04.13
인그레스 컨트롤러 설치  (0) 2025.04.05
helm 설치  (0) 2025.04.05
공인인증서 만들기  (0) 2025.04.04

쿠버네티스에 설치된 프로그램의 서비스를 외부로 노출시킬때 필요한 s/w 입니다.

인프라에 L7스위치 장비같은 역할을 한다고 보면 됩니다.

 

저장소 등록

PS C:\Users\ky945> helm repo add syrepo-ingress-nginx https://kubernetes.github.io/ingress-nginx
"syrepo-ingress-nginx" has been added to your repositories

# syrepo-ingress-nginx 이름으로 저장소를 등록합니다

PS C:\Users\ky945> helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "syrepo-ingress-nginx" chart repository
Update Complete. ⎈Happy Helming!⎈

# chart 정보를 최신화 합니다.

 

설치

PS C:\Users\ky945> helm install sy-ingress  syrepo-ingress-nginx/ingress-nginx `
>> --set controller.publishService.enabled=true `
>> --namespace syns-ingress `
>> --create-namespace `
>> --set fullnameOverride=syingress

# sy-ingress : 대문자는 불가합니다. 소문자로 정의합니다.
# syingress : helm이 생성하는 자원이름이 길어서 이름을 짧게 지정합니다.

NAME: sy-ingress
LAST DEPLOYED: Tue Apr  8 20:59:27 2025
NAMESPACE: syns-ingress
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The ingress-nginx controller has been installed.
It may take a few minutes for the load balancer IP to be available.
You can watch the status by running 'kubectl get service --namespace syns-ingress syingress-controller --output wide --watch'

An example Ingress that makes use of the controller:
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: example
    namespace: foo
  spec:
    ingressClassName: nginx
    rules:
      - host: www.example.com
        http:
          paths:
            - pathType: Prefix
              backend:
                service:
                  name: exampleService
                  port:
                    number: 80
              path: /
    # This section is only required if TLS is to be enabled for the Ingress
    tls:
      - hosts:
        - www.example.com
        secretName: example-tls

If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:

  apiVersion: v1
  kind: Secret
  metadata:
    name: example-tls
    namespace: foo
  data:
    tls.crt: <base64 encoded cert>
    tls.key: <base64 encoded key>
  type: kubernetes.io/tls

 

설치확인

PS C:\Users\ky945> k get all -n syns-ingress
NAME                                        READY   STATUS    RESTARTS   AGE
pod/syingress-controller-7bc7974579-bn7cd   1/1     Running   0          5m32s

NAME                                     TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
service/syingress-controller             LoadBalancer   10.96.57.3     localhost     80:31349/TCP,443:31682/TCP   5m32s
service/syingress-controller-admission   ClusterIP      10.106.91.44   <none>        443/TCP                      5m32s

NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/syingress-controller   1/1     1            1           5m32s

NAME                                              DESIRED   CURRENT   READY   AGE
replicaset.apps/syingress-controller-7bc7974579   1         1         1       5m32s

# syns-ingress 네임스페이스에 생성된 자원을 확인합니다.
# 80:31349/TCP,443:31682/TCP : 현재 외부에서 80,443으로 접근할수있고, 그에대한 nodeport는 31349, 31682 입니다.

테스트로 nginx web을 설치하고 외부에서 접근이 잘되는지 확인하겠습니다.

PS C:\Users\ky945> helm repo add syrepo-bitnami https://charts.bitnami.com/bitnami
"syrepo-bitnami" has been added to your repositories

# bitnami 저장소를 추가합니다

PS C:\Users\ky945> helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "syrepo-ingress-nginx" chart repository
...Successfully got an update from the "syrepo-bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

# 저장소 목록 내용을 최신화 합니다.

 

nginx web 을 설치합니다.

PS C:\Users\ky945> helm install sy-nginx syrepo-bitnami/nginx `
>> --set service.type=ClusterIP `
>> --set ingress.enabled=true `
>> --set ingress.hostname=www.sytech.store `
>> --set ingress.ingressClassName=nginx `
>> --namespace syns-nginx --create-namespace

# www.sytech.store : 가비아에서 생성한 도메인주소입니다. 도메인에 IP주소는 로컬PC에 IP 입니다.
# 외부에서 접속될 수 있도록 ingress도 함께 생성이 됩니다.

NAME: sy-nginx
LAST DEPLOYED: Sun Apr  6 09:39:34 2025
NAMESPACE: syns-nginx
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 19.0.4
APP VERSION: 1.27.4

Did you know there are enterprise versions of the Bitnami catalog? For enhanced secure software supply chain features, unlimited pulls from Docker, LTS support, or application customization, see Bitnami Premium or Tanzu Application Catalog. See https://www.arrow.com/globalecs/na/vendors/bitnami for more information.

** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:

    sy-nginx.syns-nginx.svc.cluster.local (port 80)

To access NGINX from outside the cluster, follow the steps below:

1. Get the NGINX URL and associate its hostname to your cluster external IP:

   export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
   echo "NGINX URL: http://www.sytech.store"
   echo "$CLUSTER_IP  www.sytech.store" | sudo tee -a /etc/hosts

# 저는 가비아에서 도메인주소를 생성했고, IP도 등록했습니다. 1번은 안해도 됩니다.
# 로컬PC hosts 파일에 www.sytech.store 도메인에 IP 값이 없으면, 외부 DNS서버에서 IP주소를 찾게됩니다.

WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
  - cloneStaticSiteFromGit.gitSync.resources
  - resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

 

설치확인

PS C:\Users\ky945> k get all -n syns-nginx
NAME                            READY   STATUS    RESTARTS   AGE
pod/sy-nginx-5b9d5dc569-lhfcf   1/1     Running   0          12m

NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/sy-nginx   ClusterIP   10.101.82.163   <none>        80/TCP,443/TCP   12m

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/sy-nginx   1/1     1            1           12m

NAME                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/sy-nginx-5b9d5dc569   1         1         1       12m

# syns-nginx 네임스페이스에 생성된 pod, service, deploy, replica 확인합니다.

 

또한, 생성된 ingress 정보를 확인합니다.

PS C:\Users\ky945> k describe ingress -n syns-nginx
Name:             sy-nginx
Labels:           app.kubernetes.io/instance=sy-nginx
                  app.kubernetes.io/managed-by=Helm
                  app.kubernetes.io/name=nginx
                  app.kubernetes.io/version=1.27.4
                  helm.sh/chart=nginx-19.0.4
Namespace:        syns-nginx
Address:          localhost
Ingress Class:    nginx        # 접속 트래픽을 처리하는 Ingress Controller를 지정합니다.
Default backend:  <default>
Rules:
  Host              Path  Backends
  ----              ----  --------
  www.sytech.store
                    /   sy-nginx:http (10.1.0.42:8080)   # sy-nginx 파드 8080포트로 트래픽을 전달합니다.
Annotations:        meta.helm.sh/release-name: sy-nginx
                    meta.helm.sh/release-namespace: syns-nginx
Events:
  Type    Reason  Age                From                      Message
  ----    ------  ----               ----                      -------
  Normal  Sync    17m (x2 over 18m)  nginx-ingress-controller  Scheduled for sync
  
# Ingress 단순히 정책일 뿐입니다.처리는 Ignress Controller가 합니다.
# 외부에서 http 80포트로 접근하면 sy-nginx 파드 8080포트로 전달합니다.

 

외부에서 http://www.sytech.store 접속하여 아래처럼 초기화면이 보이면 성공입니다.

 

 

'쿠버네티스 환경' 카테고리의 다른 글

CI/CD 테스트2  (0) 2025.04.17
Bamboo 설치  (0) 2025.04.13
Bitbucket 설치  (0) 2025.04.09
helm 설치  (0) 2025.04.05
공인인증서 만들기  (0) 2025.04.04

kubernetes용 패키지 관리자 라고 생각하면 됩니다.

저는 윈도우11 docker desktop 에서 쿠버네티스를 활성화해서 사용하므로 윈도우11에 helm을 설치합니다.

Chocolatey 설치

윈도우용 패키지 관리자입니다. 

Chocolatey를 이용해서 helm을 설치합니다.

Powershell 을 관리자 권한으로 실행하고 다음을 실행합니다.

PS C:\Users\ky945> Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

 

Powershell을 닫고, 다시 관리자 권한으로 실행합니다.

PS C:\Users\ky945> choco --version
2.4.3  

# 버전나오면 설치성공

 

Helm 설치

PS C:\Users\ky945> choco install kubernetes-helm

...
< 중간 생략 >
...

PS C:\Users\ky945> helm version
version.BuildInfo{Version:"v3.17.1", GitCommit:"980d8ac1939e39138101364400756af2bdee1da5", GitTreeState:"clean", GoVersion:"go1.23.5"}

# 버전정보 나오면 설치성공

 

'쿠버네티스 환경' 카테고리의 다른 글

CI/CD 테스트2  (0) 2025.04.17
Bamboo 설치  (0) 2025.04.13
Bitbucket 설치  (0) 2025.04.09
인그레스 컨트롤러 설치  (0) 2025.04.05
공인인증서 만들기  (0) 2025.04.04

Let’s Encrypt 에서 무료로 공인인증서를 만들어줍니다.

 

도메인생성

도메인이 있어야 공인인증서를 만들수 있습니다.

가비아에서 저렴한 도메인을 구매할수있습니다.

아래 가비아 사이트에 접속합니다.

https://www.gabia.com/

 

웹을 넘어 클라우드로. 가비아

그룹웨어부터 멀티클라우드까지 하나의 클라우드 허브

www.gabia.com

 

회원가입을 하고 로그인합니다.

상단 도메인 -> 도메인검색 으로 들어가서 원하는 도메인을 검색하고 선택하여 결제합니다.

저는 저렴한 sytech.store 를 구매하였습니다.

 

DNS 레코드추가

My가비아 -> DNS관리툴 -> sytech.store 설정 클릭 -> 레코드 수정 -> 다음 값을 입력합니다.

 

- 타입 : A

- 호스트 : www

- 값/위치 : 192.168.0.7   <---- 제 PC 로컬 IP주소입니다.

 

모두 입력하고 확인 ->  저장을 클릭합니다.

다음처럼 나오면 성공입니다.

 

ACME 설치

아래 사이트 접속해서 설치파일 다운로드합니다.

https://www.win-acme.com/

 

win-acme

win-acme This is a ACMEv2 client for Windows that aims to be very simple to start with, but powerful enough to grow into almost every scenario. A very simple interface to create and install certificates on a local IIS server A more advanced interface for m

www.win-acme.com

 

wacs.exe 실행합니다.

M: Create certificate (full options) 선택
2: Manual input 선택
Host : ---> *.sytech.store 입력합니다.
Friendly name '[Manual] *.sytech.store'. <Enter> to accept or type desired name: 엔터입력
4: Single certificate 선택
6: [dns] Create verification records manually (auto-renew not possible) 선택
2: RSA key 선택
2: PEM encoded files (Apache, nginx, etc.) 선택
File path: C:\Users\ky945\sytech.store.ssl ---> 인증서파일 저장위치 입력합니다.
1: None 선택
5: No (additional) store steps 선택
3: No (additional) installation steps 선택
Open in default application? (y/n*) n 선택
Do you agree with the terms? (y*/n)  y 선택
Enter email(s) for notifications about problems and abuse (comma-separated): --> 개인이메일입력

 

다음 3개의 값이 출력됩니다.

이 값들을 My가비아 -> DNS관리툴 -> sytech.store 설정 클릭 -> 레코드 수정  에 입력합니다.

Record: _acme-challenge.sytech.store   <---- _acme-challenge 이것만 사용하세요
Type: TXT
Content: "oRgY0rKDz8hK9903Xhd9NvDBtoDqgUBfydvlMcCn4Lg"  <--- " 기호 빼고 사용하세요

 

wacs으로 돌아와서 Enter 합니다.

가비아사이트로 다시 돌아가서 3개의 값을 입력한 레코드를 삭제하라고합니다. 바로 삭제합니다.

wacs으로 돌아와서 Enter 합니다.

Do you want to specify the user the task will run as? (y/n*) n 선택
Q: Quit 선택

 

C:\Users\ky945\sytech.store.ssl 위치에 인증서 파일이 보이면 성공입니다.

 

'쿠버네티스 환경' 카테고리의 다른 글

CI/CD 테스트2  (0) 2025.04.17
Bamboo 설치  (0) 2025.04.13
Bitbucket 설치  (0) 2025.04.09
인그레스 컨트롤러 설치  (0) 2025.04.05
helm 설치  (0) 2025.04.05

개발한 웹프로그램을 도커 이미지로 만들고, K3s에 배포하여 서비스하도록 구성합니다. 

그전에 몇가지 준비를 성공해야합니다.

 

준비. ArgoCD, Gitlab, Gitlab container registry 설치

먼저 아래 글 내용을따라 설치구성합니다.

 

2025.03.29 - [devops] - ArgoCD 설치구성v2

 

ArgoCD 설치구성v2

윈도우11 도커기반에 K3s에서 설치구성하였습니다.사설인증서를 적용하여 https 암호화 통신되어, PC 웹브라우저에서 https로 접속할때 안전한 접속이라고 나오게 됩니다.  https 통신을 위해 사설

syjb.tistory.com

 

2025.03.30 - [devops] - Gitlab 설치구성v2

 

Gitlab 설치구성v2

윈도우11에서 도커기반으로 설치구성하였고, 사설인증서를 적용하여 https 통신이 되도록 하였습니다.간단히 빌드,배포 명령어가 실행되는지도 확인하였습니다. 먼저 https 통신을 위해 사설인증

syjb.tistory.com

 

2025.03.28 - [devops] - Gitlab container registry 설치구성

 

Gitlab container registry 설치구성

윈도우11에서 도커기반으로 설치구성하였고, 사설인증서를 적용하여 https 통신이 되도록 하였습니다.테스트로 윈도우11에서 nginx 이미지를 build하고 push까지 성공하였습니다. 먼저 https 통신을

syjb.tistory.com

 

준비. 도커이미지 생성 및 push

앞전에 Gitlab container registry 설치구성시에 생성한 이미지를 그대로 사용하겠습니다.

  • 작업디렉토리 : C:\Users\ky945\SYimage
  • 파일 : index.html, Dockerfile

준비. Gitlab저장소 생성

앞전에 Gitlab 설치구성시에 생성한 저장소를 그대로 사용하겠습니다.

  • 작업디렉토리 : C:\Users\ky945\SYgit

준비. Gitlab 접근 토큰생성

ArgoCD 와 containerd 가 registry에 접근하게 됩니다.

Gitlab에 엑세스 토큰을 이용하여 Gitlab repository 와 container registry 에 접근하도록 합니다.

Gitlab 로그인 -> 상단 아이콘 클릭 -> Edit profile -> Access tokens -> Add new token 클릭

아래 값을 입력하고 "Create personal access token" 클릭하면 token 값이 생성됩니다.

token name : SYtoken
Select scopes : read_repository, write_repository, read_registry, write_registry 

#토큰값 : glpat-5d3yb4HrWysGbrPTn-ou

 

준비. containerd에 인증서 설정

containerd가 registry에 접근하기위해 regist.sytech.com  도메인을 인증하려고합니다.

/etc/rancher/k3s/registries.yaml 파일을 생성하고 다음 내용을 추가합니다.

mirrors:
  "regist.sytech.com:5050":
    endpoint:
      - "https://regist.sytech.com:5050"

configs:
  "regist.sytech.com:5050":
    tls:
      ca_file: "/etc/SYssl/sytech.com.crt"

주의!! 파일저장후 K3s 재기동 해야합니다.

 

준비. containerd에 registry 접근설정

containerd가 registry에 접근하기위한 로그인/패스워드 정보가 필요합니다.

K3s에 imagePullSecret 생성합니다.

~ #  kubectl create secret docker-registry sy-gitlab-sec \
> --docker-server=regist.sytech.com:5050 \
> --docker-username=SYtoken \
> --docker-password=glpat-5d3yb4HrWysGbrPTn-ou \
> --docker-email=admin@sytech.com \
> -n default
secret/sy-gitlab-sec created   <--- 성공입니다.
~ #

 

준비. ArgoCD에 SSL인증서 적용

ArgoCD가 Gitlab에 https://gitlab.sytech.com/root/sygitops.git 접근하기전에 인증서정보를 적용해야합니다.

다음처럼 정해진 configmap에 인증서값을 적용합니다.

# K3s에 진입해서 작업합니다.
vi sy-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-tls-certs-cm
  namespace: argocd
data:
  gitlab.sytech.com: |
    -----BEGIN CERTIFICATE-----
    MIIDMDCCAhigAwIBAgIUVhlt6J3LHR27fWwmMJMSot5cGLgwDQYJKoZIhvcNAQEL
    BQAwFTETMBEGA1UEAwwKc3l0ZWNoLmNvbTAeFw0yNTAzMjExMjE5MDZaFw0yNjAz
    MjExMjE5MDZaMBUxEzARBgNVBAMMCnN5dGVjaC5jb20wggEiMA0GCSqGSIb3DQEB
    AQUAA4IBDwAwggEKAoIBAQC0nv17dLCz087VXLZ/slv3J1AIG87a6klu8PANzYXD
    R22Bi8aWcPCSc9Lvgb21b+mG2JjReaiqVpIMsnIJjSKCkaeGZ12VLy6lMX2qMuPn
    8lBeF6ZGc3NYyWCSCVPiTnVqtIwBaw6+xTDEnowDAzWGFjGgXTpQPByfc1LboV2i
    vXiLdg6cwSBDX+xgPmL88XMxZmTba3psyMeqI+AVjAdVpEPOqpnrC60mOK6slJLS
    v0yTZ21i4eX098Qib0aEFgzAmoUMWmrELCVWuanORM341JtOcIHnTX/DVJWqF+/g
    WyiBfEGIGrPsSgKbHM6VN0hNj5ptEYR9g66F64yH84jrAgMBAAGjeDB2MB0GA1Ud
    DgQWBBTJKVd711Q14Sgf1RN/hQab1hbT8TAfBgNVHSMEGDAWgBTJKVd711Q14Sgf
    1RN/hQab1hbT8TAPBgNVHRMBAf8EBTADAQH/MCMGA1UdEQQcMBqCCnN5dGVjaC5j
    b22CDCouc3l0ZWNoLmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAmyQ6Tl9AmyFgTobV
    DVbwwKqMAsv+csKGANURn8kHrf3REMGyucO+pBxb4nEOdK9AX+sdBo5x4KUkOI8e
    UkTH4AK2IAlXfH2NssD4/KQq0BU7rceI2e9FijZNGbMBoByvkDgmOaSkVOgtzfeN
    HwRLZteQvm/YLBQZtR/TBK2pS+oBcInDuDozz5QRhNc3vsJwuvXIxrgRFEpKTf+O
    IwU8IKvgbMoPP7mE+75lbs6nh8wMLRRy50c19ADZ+LcFJY47Rf762qmPboymM2RC
    DovjGOo/w4Ai3KeSn5Sg9PhaawBHmbaWqaShsvi86RDM8wEUp16XxM6uguSG3nYW
    FLU8Uw==
    -----END CERTIFICATE-----

# argocd-tls-certs-cm : 정해진 이름입니다. 변경하면 안됩니다.

# configmap을 적용합니다.
kubectl apply -f sy-configmap.yaml
configmap/argocd-tls-certs-cm configured

준비가 성공적으로 끝났으면 어플리케이션을 배포해보도록 하겠습니다.

 

매니페스트파일 생성

K3s에 배포할 컨테이너이미지 와 서비스 포트를 작성합니다.

PS C:\Users\ky945\SYgit> notepad deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sy-nginx
  labels:
    app: sy-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sy-nginx
  template:
    metadata:
      labels:
        app: sy-nginx
    spec:
      containers:
      - name: sy-nginx
        image: regist.sytech.com:5050/root/sygitops/sy-nginx:latest
        ports:
        - containerPort: 80
      imagePullSecrets:
        - name: sy-gitlab-sec

# sy-gitlab-sec : registry 접근을 위한 로그인/패스워드 정보가 있는 secret 지정

 

service 파일 생성

외부로 서비스를 오픈할 정보를 작성합니다.

PS C:\Users\ky945\SYgit> notepad service.yaml

apiVersion: v1
kind: Service
metadata:
  name: sy-nginx
spec:
  type: NodePort
  selector:
    app: sy-nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30080

 

저장소로 push

PS C:\Users\ky945\SYgit> git add .

PS C:\Users\ky945\SYgit> git commit -m "deploy, service 파일추가"
[main eec5ea6] deploy, service 파일추가
 2 files changed, 34 insertions(+)
 create mode 100644 deployment.yaml
 create mode 100644 service.yaml
 
PS C:\Users\ky945\SYgit> git push -u origin main
git: 'credential-manager-core' is not a git command. See 'git --help'.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 678 bytes | 678.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://gitlab.sytech.com/root/sygitops.git
   6e78cd1..eec5ea6  main -> main
branch 'main' set up to track 'origin/main'.

 

ArgoCD에서 Repository 연결

ArgoCD 로그인 -> Settings -> CONNECT REPO -> 아래 내용 입력후 CONECT 클릭합니다.

Choose your connect method : VIA HTTPS
Type : git
Name : sy-repository
Project : default
Repository URL : https://gitlab.sytech.com/root/sygitops.git
Username : SYtoken
Password : glpat-5d3yb4HrWysGbrPTn-ou

 

CONNECTION STATUS 가 Successful 나오면 성공입니다.

 

AgroCD에서 어플리케이션을 생성합니다.

왼쪽 Applications -> 상단 NEW APP -> 다음값을 입력하고 상단에 CREATE 클릭

Application Name : sy-nginx-app
Project Name : default
Repository URL : https://gitlab.sytech.com/root/sygitops.git
Path : .
Cluster URL : https://kubernetes.default.svc
Namespace : default

 

sy-nginx-app 박스가 생기면 성공입니다.

 

작은 박스안에 SYNC 클릭하고 기다리면 Status에 Healthy 와 Synced 가 green색으로 보이면 성공입니다.

'도커 환경' 카테고리의 다른 글

사설인증서 생성  (1) 2025.03.30
Gitlab 설치구성v2  (0) 2025.03.30
ArgoCD 설치구성v2  (0) 2025.03.29
Gitlab container registry 설치구성  (0) 2025.03.28

Gitlab 과 ArgoCD 를 https로 접근하기 위해 사설인증서를 생성합니다.

웹브라우져에서 "이 연결은 안전합니다." 라고 나오게 됩니다.

 

사설인증서 생성
저는 윈도우 git 클라이언트 설치해서 git bash 이용하였습니다.

윈도우용 openssl 설치해서 사용도 가능합니다.

# Git bash 에서 실행합니다.
$ mkdir -p SYssl
$ cd SYssl

# 인증서를 생성합니다.
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
        -keyout sytech.com.key -out sytech.com.crt \
        -subj "/CN=sytech.com" \
        -addext "subjectAltName=DNS:sytech.com,DNS:*.sytech.com"
        
# "/CN=sytech.com" : sytech.com에 모든 서브도메인을 인증하도록 적용
# "subjectAltName=DNS:sytech.com,DNS:*.sytech.com" : 이값도 있어야 모든 서브도메인 인증가능함

주의!! CN 과 subjectAltName 값이 있어야 와일드카드 인증서를 문제없이 이용가능합니다.

 

도메인주소 추가
별도 자체 DNS 서버가 없으므로, 윈도우에 hosts 파일을 이용하였습니다.
파일에 아래 IP와 도메인주소를 추가합니다.

# PowerShell을 관리자 권한으로 실행하고 notepad로 파일을 수정합니다. 그래야 파일이 저장됩니다.
PS C:\WINDOWS\system32> notepad C:\Windows\System32\drivers\etc\hosts

# 샘플입니다.
192.168.0.7    argocd.sytech.com   # ArgoCD 서비스 ip와 도메인 추가
192.168.0.7    gitlab.sytech.com   # Gitlab 서비스 ip와 도메인 추가
192.168.0.7    regist.sytech.com   # Gitlab container registry 서비스 ip와 도메인 추가

 

인증서 설치
사설인증서를 신뢰할수있는 루트인증기관으로 PC에 등록합니다.
윈도우PC -> sytech.com.crt 파일 우클릭 -> 인증서설치 -> 저장소 위치 -> '현재 사용자' 선택 -> '모든 인증서를 다음 저장소에 저장' 선택 -> 찾아보기 -> '신뢰할 수 있는 루트 인증 기관' 선택

 

주의!! 사설인증서생성, 도메인주소추가, 인증서설치를 모두 정상 완료해야 인증서 사용에 문제가 없습니다.

'도커 환경' 카테고리의 다른 글

Gitops 구성하기v2  (0) 2025.03.30
Gitlab 설치구성v2  (0) 2025.03.30
ArgoCD 설치구성v2  (0) 2025.03.29
Gitlab container registry 설치구성  (0) 2025.03.28

윈도우11에서 도커기반으로 설치구성하였고, 사설인증서를 적용하여 https 통신이 되도록 하였습니다.
간단히 빌드,배포 명령어가 실행되는지도 확인하였습니다.

 

먼저 https 통신을 위해 사설인증서를 준비합니다.

2025.03.30 - [devops] - 사설인증서 생성

 

사설인증서 생성

Gitlab 과 ArgoCD 를 https로 접근하기 위해 사설인증서를 생성합니다.웹브라우져에서 "이 연결은 안전합니다." 라고 나오게 됩니다. 사설인증서 생성저는 윈도우 git 클라이언트 설치해서 git bash 이

syjb.tistory.com

 

Gitlab 기동 및 설정

PS C:\Users\ky945> docker run -d --name SYgitlab `
       -p 443:443 `
       -v C:\Users\ky945\SYssl:/etc/gitlab/ssl `
       gitlab/gitlab-ce:latest

# -p 443:443 : Gitlab 서비스 포트로 설정합니다.
# -v C:\Users\ky945\SYssl:/etc/gitlab/ssl : ssl 인증서파일을 마운트합니다.

 
Gitlab이 모두 기동완료되기 까지 기다립니다.

# 컨테이너로 진입합니다.
PS C:\Users\ky945> docker exec -it SYgitlab /bin/bash

# 기동완료되기까지 모니터링 합니다.
watch gitlab-ctl status

Gitlab 설정파일 수정

# Gitlab 컨테이너에서 계속 진행합니다
# 설정파일을 오픈합니다.
vi /etc/gitlab/gitlab.rb

# 32라인
# 외부에서 Gitlab 접근시에 사용하는 도메인주소 입력
external_url 'https://gitlab.sytech.com'

# 1721,1722 라인
# 사설인증서 파일 위치 입력
nginx['ssl_certificate'] = "/etc/gitlab/ssl/sytech.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/sytech.com.key"

# 컨테이너를 빠져 나옵니다.
# 호스트에서 컨테이너 재기동
PS C:\Users\ky945> docker restart SYgitlab

 

Gitlab 접속확인

PC 웹브라우져에서 https://gitlab.sytech.com 접속합니다.

로그인 계정은 root 이고, 초기 패스워드 정보는 다음처럼 확인합니다.

# 컨테이너로 진입합니다.
PS C:\Users\ky945> docker exec -it SYgitlab /bin/bash

# 파일에 Password 부분을 확인합니다.
grep ^Pass /etc/gitlab/initial_root_password

 

로그인 되면 성공입니다.


빌드,배포 테스트 해보기

추가로 Gitlab-runner 를 설치해야합니다. 쉽게 말해 일을 시키는 매니저입니다.

PS C:\Users\ky945> docker run -d --name SYgitlab-runner `
      -v C:\Users\ky945\SYssl:/etc/SYssl:ro `
      gitlab/gitlab-runner
      
# C:\Users\ky945\SYssl:/etc/SYssl:ro : runner 등록할때 인증서 파일이 필요합니다.

 

Gitlab에 접속해서 runner를 등록해야합니다.

Gitlab로그인 -> 하단 Admin -> CI/CD -> Runners -> 아래값 입력후 Create runner 클릭

 Tags : SYbuild, SYdeploy 
 
 # SYbuild : CI파일에서 빌드하는 부분을 지정하는 나만에 단어입니다. 
 # SYdeploy : CI파일에서 배포하는 부분을 지정하는 나만에 단어입니다.

 

화면이 바뀌면서 안내 페이지가 보입니다.

주의!! token값을 사용해야합니다. 페이지를 나오지 말고 그대로 유지시킵니다.

이 상태에서 Gitlab-runner 컨테이너로 진입하고 다음 명령어를 실행합니다.

# Gitlab-runner 컨테이너로 진입합니다.
docker exec -it SYgitlab-runner /bin/bash

# runner를 등록합니다.
gitlab-runner register \                             
    --url https://gitlab.sytech.com \
    --token glrt-t1_NotdgSzy_iU3kU4rhuax \
    --executor shell \
    --name SYrunner \
    --tls-ca-file /etc/SYssl/sytech.com.crt

# --token : 안내페이지 Step 1 에 있는 토큰값을 입력합니다.
# --tls-ca-file : gitlab.sytech.com 도메인에 인증서파일 위치를 지정합니다.

# 이후부터는 설정한 값들이 맞는건지 물어봅니다.
# 계속 엔터 엔터 치시면됩니다.

주의!! 인증서파일을 지정하지 않으면 신뢰되지않는 인증서 에러 납니다.

 

안내 페이지 하단에 "You've registered a new runner!" 나오면 등록이 성공된겁니다.

 

다음으로 프로젝트를 하나 생성합니다. 

Create a project -> Create blank project -> 다음처럼 입력하고 Create porject 클릭

# 프로젝트 이름
Project name : SYgitops

# 계정을 선택
Project URL : root

# 프로젝트 이름 입력되면 자동입력됩니다. 대문자는 소문자로 변환됨
Project slug : sygitops

 

PC와 Gitlab 간에 연결구성합니다.

먼저 윈도우용 Git Client를 설치합니다.

https://git-scm.com/downloads/win

 

Git - Downloading Package

Download for Windows Click here to download the latest (2.49.0) 64-bit version of Git for Windows. This is the most recent maintained build. It was released on 2025-03-17. Other Git for Windows downloads Standalone Installer 32-bit Git for Windows Setup. 6

git-scm.com

 

Git Client 설치완료하고 PowerShell에서 다음 명령어를 실행합니다.

# 작업 디렉토리 생성
PS C:\Users\ky945> mkdir SYgit
PS C:\Users\ky945> cd SYgit

# 로컬에 Git 초기화
PS C:\Users\ky945\SYgit> git init
Initialized empty Git repository in C:/Users/ky945/SYgit/.git/

# 원격 Git 저장소 등록
PS C:\Users\ky945\SYgit> git remote add origin https://gitlab.sytech.com/root/sygitops.git

# Main 브랜치 연결
PS C:\Users\ky945\SYgit> git branch -M main

# Git 저장소 main에 파일을 다운로드 받습니다.
PS C:\Users\ky945\SYgit> git pull origin main
warning: missing OAuth configuration for gitlab.sytech.com - see https://aka.ms/gcm/gitlab for more information

#여기서 "Connect to Gitlab" 작은 팝업창이 뜨면서 Username 과 token을 입력하라고 나옵니다.
#최초연결시에만 나옵니다. 저는 Password 방식으로 선택해서 Username, Password 입력하고 "Sign in" 하였습니다.

git: 'credential-manager-core' is not a git command. See 'git --help'.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (3/3), 2.77 KiB | 258.00 KiB/s, done.
From https://gitlab.sytech.com/root/sygitops
 * branch            main       -> FETCH_HEAD
 * [new branch]      main       -> origin/main

# Git 저장소에 다운로드 받은 파일을 확인합니다.
# README.md 파일이 보이면 성공입니다.
PS C:\Users\ky945\SYgit> ls -Force

    디렉터리: C:\Users\ky945\SYgit

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d--h--      2025-03-30   오전 9:54                .git
-a----      2025-03-30   오전 9:54           6255 README.md

 

CI파일을 생성합니다.

간단하게 빌드할때 실행할 명령어, 배포할때 실행할 명령어를 작성합니다.

주의!! gitlab-ci.yml 파일명 은 정해진겁니다. 다른파일명 안됩니다.

PS C:\Users\ky945\SYgit> notepad .gitlab-ci.yml

stages:
  - build
  - deploy

build-job:
  stage: build
  tags:
    - SYbuild
  script:
    - echo "Building the application..."
    - hostname
    - echo "Build complete."

deploy-job:
  stage: deploy
  tags:
    - SYdeploy
  script:
    - echo "Deploying to Test server"
    - hostname
    - echo "Deployment complete."

# SYbuild, SYdeploy : Gitlab-runner 생성할때 입력한 tag 값과 동일하게 입력합니다.

 

CI파일을 Gitlab 저장소로 push 하고 Pipelines 결과를 확인합니다.

# 현재 생성된 파일을 추가합니다.
PS C:\Users\ky945\SYgit> git add .

# 설명을 작성합니다.
PS C:\Users\ky945\SYgit> git commit -m ".gitlab-ci.yml 파일추가됨"
[main 4f4fabd] .gitlab-ci.yml 파일추가됨
 1 file changed, 21 insertions(+)
 create mode 100644 .gitlab-ci.yml
 
# Git저장소에 최종 push 합니다.
PS C:\Users\ky945\SYgit> git push -u origin main
git: 'credential-manager-core' is not a git command. See 'git --help'.
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 460 bytes | 460.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://gitlab.sytech.com/root/sygitops.git
   caf6829..4f4fabd  main -> main
branch 'main' set up to track 'origin/main'.
PS C:\Users\ky945\SYgit>

 

Gitlab 좌측 Build -> Pipelines -> Passed 보이면 성공입니다.

 

'도커 환경' 카테고리의 다른 글

Gitops 구성하기v2  (0) 2025.03.30
사설인증서 생성  (1) 2025.03.30
ArgoCD 설치구성v2  (0) 2025.03.29
Gitlab container registry 설치구성  (0) 2025.03.28

윈도우11 도커기반에 K3s에서 설치구성하였습니다.

사설인증서를 적용하여 https 암호화 통신되어, PC 웹브라우저에서 https로 접속할때 안전한 접속이라고 나오게 됩니다. 

 

https 통신을 위해 사설인증서를 준비합니다. 

 

2025.03.30 - [devops] - 사설인증서 생성

 

사설인증서 생성

Gitlab 과 ArgoCD 를 https로 접근하기 위해 사설인증서를 생성합니다.웹브라우져에서 "이 연결은 안전합니다." 라고 나오게 됩니다. 사설인증서 생성저는 윈도우 git 클라이언트 설치해서 git bash 이

syjb.tistory.com

 

K3s 설치
K8s는 경량버전인 K3s를 설치해서 ArgoCD설치를 준비합니다.

# PowerShell 에서 실행합니다.
docker run -d --privileged --name SYk3s `
       -p 8443:30443 `
       -v C:\Users\ky945\SYssl:/etc/SYssl:ro `
       rancher/k3s:latest server

# -p 8443:30443 : argoCD 외부 노출포트 https용 8443 설정합니다.
# C:\Users\ky945\SYssl : 컨테이너에서 사설인증서를 마운트합니다.
# server : 서버모드로 기동합니다.

주의! docker run 옵션에 server 넣어야합니다. 없으면 기동에 실패합니다.
  
argo CD 설치

# PowerShell에서 실행합니다.
# K3s 컨테이너로 진입합니다.
docker exec -it SYk3s /bin/sh

# argoCD 용 네임스페이스 생성
kubectl create namespace argocd
  
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

# 모든 pod가 기동될때까지 대기 
watch kubectl get pods -A


argoCD deployment 수정
아래 Traefik Ingress를 이용하여 ArgoCD를 외부로 https를 노출할겁니다. 
그럼 웹브라우저와 Ingress는 https 통신을 하고, Ingres와 AcrgoCD는 http로 통신하게 됩니다.
그런데 argoCD는 기본적으로 http로 접근하는걸 https로 리다이렉션 합니다.
그래서 웹브라우져에서 ArgoCD 접속시 "리다이렉션 무한반복" 에러가 생깁니다.
ArgoCD을 기동할때 리다이렉션 안하게 해줘야 해결됩니다. (원인찾는데 시간많이 걸림)

kubectl patch deployment argocd-server -n argocd --type='json' \
        -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--insecure"}]'

주의! insecure 추가하지않으면 웹브라우저에서 리다이렉션 무한반복에러 발생합니다.

Secret 생성
Traefik Ingress가 https통신을위해 필요합니다.

cd /etc/SYssl
kubectl create secret tls sy-argocd-tls --cert=sytech.com.crt --key=sytech.com.key -n argocd

 
Traefik Ingress 서비스 nodeport 설정
ArgoCD를 외부로 노출하기위해 필요합니다.
서비스는 NodePort 타입으로 노출하였습니다.

kubectl patch svc traefik -n kube-system -p '{"spec": {"type": "NodePort"}}'
kubectl patch svc traefik -n kube-system -p '{"spec": {"ports": [{"port": 443, "nodePort": 30443}]}}'

# 30443 포트는 K3s 기동할때 지정한 포트번호와 일치해야함


외부노출 Ingress 생성

# 파일을 생성해 내용을 작성합니다.
vi sy-ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sy-argocd-ingress
  namespace: argocd
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
spec:
  rules:
  - host: argocd.sytech.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: argocd-server
            port:
              number: 80
  tls:
  - hosts:
    - argocd.sytech.com
    secretName: sy-argocd-tls

# websecure : 443포트로 들어오는걸 80으로 보냅니다. traefik에 기본설정인듯함.

# Ingress 생성
kubectl apply -f sy-ingress.yaml


접속 테스트
https://argocd.sytech.com:8443  접속하여 "이 연결은 안접합니다" 나오면 성공입니다. (아래그림참고)

 


어플리케이션 배포 테스트

Argo CD에 웹UI에 로그인합니다.

Username은 admin 이고, 초기 패스워드는 다음처럼 확인합니다.

# K3s 컨테이너에서 실행합니다.
kubectl get secret -n argocd argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
ZsxDlA672N6qGbTa <---- 패스워드

 

쉬운 패스워드로 변경합니다.

Agro CD 로그인 -> 왼쪽 User Info -> 위쪽 UPDATE PASSWORD -> 원하는 패스워드로 변경

 

새로운 Applications 생성합니다.

왼쪽 Applications -> 상단 NEW APP -> 다음값을 입력하고 상단에 CREATE 클릭

Application Name : sy-app
Project Name : default
Repository URL : https://github.com/argoproj/argocd-example-apps.git
Path : guestbook
Cluster URL : https://kubernetes.default.svc
Namespace : default

 

사각형 박스모양이 생기고 아래쪽 SYNC 클릭 -> Status가 Healthy 와 Synced 나오면 성공입니다.

 

 

 

'도커 환경' 카테고리의 다른 글

Gitops 구성하기v2  (0) 2025.03.30
사설인증서 생성  (1) 2025.03.30
Gitlab 설치구성v2  (0) 2025.03.30
Gitlab container registry 설치구성  (0) 2025.03.28

+ Recent posts