참고: https://zellyshu.github.io/posts/2022-01-27-rancher-desktop-installation/

 

로컬 환경에서 간단하게 쿠버 환경 테스트 해보고자 구성 도구를 찾다가 Rancher를 알게 되었다.

해당 관련 내용 정리 예정!


Rancher Desktop

Electron으로 구현되어서 Windows, MacOS, Linux 에서 사용 가능한 것이 특징

특히 Mac의 경우 Intel 과 Silicon Mac 모두 지원

컨테이너 관리뿐만 아니라 간편하게 쿠버네티스 환경을 만들 수 있다는 것이 장점

Docs에서 자세한 내용을 확인할 수 있다.

 

 

❗ Rancher와는 다르다.. Rancher는 기업 대상으로 하는 클라우드 기반의 플랫폼 ❗

https://ksr930.tistory.com/133

  Rancher Desktop Rancher
대상 사용자 개인 기업 및 조직
기능 Kubernetes 클러스터 프로비저닝 및 관리 Kubernetes 클러스터 관리, 애플리케이션 배포 및 관리, 멀티 클라우드 관리
배포 데스크톱 운영체제 온프레미스, 클라우드 및 하이브리드 환경

Rancher Desktop 설치 및 사용

  • Rancher Desktop 설치

https://rancherdesktop.io/

위의 링크에서 환경에 맞는 걸로 설치! (나는 Windows)

관리자 권한으로 실행해야한다.

 

  • 이미지 pull

Add Image 클릭 후 hello-world 검색

pull 버튼 누르면 이미지 다운로드 완료

 

  • Windows powershell에서 실행
docker images
docker run hello-world

 

 

❗만약 이전에 eks 클러스터 연결되어 있는 상태였어서 자꾸 역할 에러 뜨면 context 변경을 해줘야한다 ❗

 kubectl config use-context rancher-desktop

'Container > Kubernetes' 카테고리의 다른 글

[Kubernetes] ArgoCD 설치  (0) 2023.09.26

AWS IoT Core 테스트를 위해 cloud9을 바탕으로 디바이스 설정하는 것보다 가상머신으로 디바이스를 만들어서 테스트 하는게 보다 정확할 것 같았다. 해당 테스트를 진행하다 생긴 문제를 해결하기 위해 공유 폴더 사용을 했다.

  • 문제: IoT Core에서 연결 키트를 받았을 때 해당 연결 키트 다운로드하면 로컬 PC에 저장하게 됨. 이를 가상머신에 공유를 해야하는데 바로 되진 않음
  • 해결: 공유 폴더를 활용해 로컬 PC의 폴더를 가상머신과 연결해 사용하자!

[테스트 환경]

  • VirtualBox: 7.0.10 ver
    • Ubuntu: ubuntu 22.04.3-desktop-amd64.iso
    • VBoxGuestAdditions_7.0.10.iso

 

가상 머신 생성

원하는 이름과 ISO Image를 넣어준다. 나는 ubuntu로 진행함!

user도 원하는대로~

내가 사용하는 ubuntu image 버전에 맞춰 기본 메모리의 경우 4GB 이상, CPU는 2 ~ 4개를 추천한다.

디스크 사이즈의 경우 25GB 이상으로 해야 해당 iso image가 설치되고 커널 패닉 오류가 생기지 않는다.

만들면 자동으로 가상 머신이 실행된다.

 

공유 폴더 생성 및 연결

원하는 이름으로 로컬 PC에 폴더를 생성한다.

해당 폴더의 속성에 들어간다.

속성의 공유 탭에서 고급 공유 → 권한 클릭

위 이미지와 같이 모든 권한을 허용해주고 확인 클릭 → 이후에 다 확인해서 폴더 공유를 완료하면 된다.

 

다시 가상머신으로 돌아와서

가상머신의 설정에서 공유 폴더 → 폴더 추가 → 위와 같이 설정해주면 된다. (설정이 끝나면 확인을 눌러 적용 시킨다.)

마운트 지점도 원하는대로 설정해준다.(나는 /home/realyun/iot/)

 

(미리 VBoxGuestAdditions_7.0.10.iso 이 친구를 다운받아서 설치를 해줘야한다!)

 

머신 내부 안 설정에서 Sharing 허용도 해줘야한다. 원하는 폴더로 지정해서 해도 좋다! (나는 iot 폴더로 지정했다..)

게스트 확장 CD 이미지 삽입을 클릭해준다.

(만약 위 이미지 처럼 메뉴가 보이지 않는다면 호스트키+C 를 누르면 된다. 호스트키는 나는 ctrl+alt로 설정한 상태!)

폴더에서 위와 같이 autorun.sh 파일을 우클릭하고 실행시켜준다.

 

공유된 폴더가 나타나도 접근 권한이 없다고 뜬다.

터미널 창에서 아래 명령어를 입력해준다.

sudo gpasswd -a <user-id> vboxsf

입력 후 reboot 진행한 뒤에 폴더에 접근이 가능해진다.

이제 원하는 파일을 생성하면 로컬 PC에도, 가상머신에도 적용된다!

'Computer Science > Operating System' 카테고리의 다른 글

[Linux] CentOS 교육 -3  (0) 2022.10.26
[Linux] CentOS 교육 -2  (0) 2022.10.26
[Linux] CentOS 교육 -1  (0) 2022.10.24
[개념] File System 2(Implementation)  (0) 2021.08.12
[개념] File System 1  (0) 2021.08.12

참고: https://catalog.us-east-1.prod.workshops.aws/workshops/de4e38cb-a0d9-4ffe-a777-bf00d498fa49/ko-KR

고객사에서 OpenSearch 서비스를 활용 중이라 무슨 서비스인지 알고 싶어서 무작정 따라해봤다..!


Amazon OpenSearch 클러스터 생성

  • create domain

테스트니까 네트워크는 퍼블릭으로, 나머지 설정들은 디폴트로 놔두면 된다..

(뭐시기 에러뜨면.. 고급 클러스터 설정 쪽 최대 절 수 그냥 1024로 설정..)

생성 완료까지 시간이 좀 걸린다.

 

AWS Blog 문서를 Amazon OpenSearch로 검색하기

  • cloud9 인스턴스 생성
  • OpenSearch - 인덱스 생성

OpenSearch 대시보드에 들어간다.

로그인의 경우 아까 클러스터 생성할 때 사용했던 ID/Password를 사용하면 된다.

해당 버튼을 클릭하고 접속한다.

private &rarr; confirm

메뉴의 Dev Tools 를 클릭한다.

(검색을 위한 index 생성하고 mapping 설정)

아래 코드 붙여넣고 화살표 클릭해서 실행

PUT /aws-blog
{
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "author": {
        "type": "keyword"
      },
      "body": {
        "type": "text"
      },
      "category": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "date": {
        "type": "date",
        "format": "dd MMM yyyy HH:mm:ss z"
      },
      "url": {
        "type": "keyword"
      }
    }
  }
}

여기까지의 단계가 AWS blog 문서들을 색인할 index를 생성한 것!

 

  • Blog 문서를 index에 저장하기

cloud9에 접속 후 아래 명령어를 입력한다.

git clone https://github.com/jinuland/aws-blog-crawler.git

해당 파일을 클릭하고 host, id, password를 입력한다. host는 OpenSearch의 도메인 엔드포인트이다.

cd aws-blog-crawler
./ingest_ko.sh

위 명령어 처럼 프로그램을 실행시킨다. (AWS Blog 글들이 OpenSearch 도메인으로 색인된다.)

 

  • OpenSearch 대시보드에서 문서 검색해보기

OpenSearch의 DevTools로 돌아가 아래처럼 입력한다.

GET /aws-blog/_search
{
  "query": {
    "match_all": {
    }
  }
}

 

Full Text 검색

  • Dev Tools에서 API 호출

(workshop 기준으론 Dev Tools로  API를 호출하지만, Application에서 검색 서비스 제공을 하고 싶으면 

API Gateway + Lambda + OpenSearch로 구현할 수 있다.)

즉, Dev Tools에서 아래처럼 쿼리를 날리면 원하는 결과를 얻을 수 있다.

# 자연어 검색
GET /aws-blog/_search
{
  "query": {
    "multi_match": {
      "query": "aws 리전 및 인프라",
      "fields": ["title","body"]
    }
  }
}

# Author 별 Aggregation
GET /aws-blog/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "title": "데이터"
          }
        }
      ]
    }
  },
  "aggs": {
    "category": {
      "terms": {
        "field": "author"
      }
    }
  }
}

위와 같이 OpenSearch를 활용한다... 

시각화를 구현하진 않았지만.. 시각화까지 가능함!

 

[OpenSearch 기능]

https://aws.amazon.com/ko/opensearch-service/features/

미리 AWS 환경은 세팅해둔 상태! (external alb - web(ec2) - was(ec2))

직접 apache와 tomcat을 올려보기 위한 작업을 할 것이다...

 

왜 web - was 분리 구성을 하는가?

https://hwanchang.tistory.com/5


WEB 서버 구성(Apache)

  • Apache 설치 및 시작
yum install -y httpd
systemctl start httpd
  • alb 의 target group 상태검사 경로 변경 

  • index.html 생성
cd /var/www/html
vi index.html

# index.html
<html>
<body>WEB-A 서버입니다.</body>
</html>
  • health check: alb dns 주소를 통해 확인

  • health check: curl 명령어 활용

 

WAS 서버 구성(Tomcat)

  • java 다운로드 & tomcat 다운로드

https://www.oracle.com/java/technologies/downloads/

https://tomcat.apache.org/에서 다운로드

tar xvzf <파일명>
cp -R <디렉토리명> /usr/local/src
  • tomcat, jdk 경로 설정
vi /etc/profile

# 경로 확인
source /etc/profile
echo $JAVA_HOME
echo $CATALINA_HOME

  • tomcat 서비스 등록
cd /etc/init.d
vi tomcat

# tomcat file
#!/bin/bash
# Startup script for the Tomcat Server
# chkconfig : 345 50 50
# description: Tomcat is a Web application server.
# processname : java
# directory :
CATALINA_HOME=/usr/local/src/apache-tomcat-10.1.11
export JAVA_HOME=/usr/local/src/jdk-17.0.8
export CATALINA_HOME=/usr/local/src/apache-tomcat-10.1.11
case "$1" in
start)
echo "Starting tomcat: "
$CATALINA_HOME/bin/startup.sh
;;
stop)
echo "Shutting down tomcat: "
$CATALINA_HOME/bin/shutdown.sh
;;
restart)
echo "Restarting tomcat: "
$CATALINA_HOME/bin/shutdown.sh
$CATALINA_HOME/bin/startup.sh
;;
*)
echo "Usage: service tomcat"
start|stop|restart
exit 1
esac
exit 0

chmod 755 tomcat
service tomcat start

  • EC2 SG에 8080 포트 오픈
  • WAS 서버 index.html 생성
cd /usr/local/src/apache-tomcat-10.1.11/webapps/ROOT
vi index.html

# index.html
<html>
<body>WAS-A 서버입니다.</body>
</html>

 

WEB 서버 - WAS 서버 연동

  • WEB 서버 내부에 httpd.conf 파일 수정
vi /etc/httpd/conf/httpd.conf

###New Configuration
<VirtualHost *:80>
    ServerName <alb-dns주소>

    ProxyPass / http://<was-ip>:8080/
    ProxyPassReverse / http://<was-ip>:8080/
</VirtualHost>

systemctl restart httpd.service
  • WAS 서버
cd /usr/local/src/tomcat/bin
./shutdown.sh
./startup.sh
  • alb dns 접속 시 WAS 화면이 뜨면 성공 

 

 

참고: https://sweetysnail1011.tistory.com/57

 

❗java 다운받을 때 프로세서 확인 꼭 하기 uname -i 명령어 활용❗

'Computer Science > DevOps' 카테고리의 다른 글

[Monitoring] Monitoring vs Observability  (0) 2025.01.13
[Jenkins] 다양한 플러그인 활용  (0) 2023.07.24
[Jenkins] Jenkins Pipeline 구축  (0) 2023.07.03
[Jenkins] Jenkins 다뤄보기  (0) 2023.06.27
[OS] OS 모음집  (0) 2021.08.12

Slack 연결

  • 목적: ChatOps
  • slack 채널 생성(무료플랜)

  • Jenkins Plugin 설치

slack notification 플러그인 설치

  • slack 앱 추가

Jenkins CI 추가

  • Jenkins에 slack 연결

자격 증명 추가(secret text로)
slack 자격증명 확인

  • 연결 확인

저장 후 빌드 시작
알림 확인

# Jenkinsfile

node {

  // job
  try {
    stage('build') {
      println('so far so good...')
    }
    stage('test') {
      println('A test has failed!')
      sh 'exit 1'
    }
  } catch(e) {
    // mark build as failed
    currentBuild.result = "FAILURE";

    // send slack notification
    slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")

    // throw the error
    throw e;
  }
}

Sonarqube 연결

  • docker-compose 활용하여 Sonarqube 설치
mkdir jenkins 
cd jenkins
vi docker-compse.yml
  
# docker compose 설치
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

docker-compse up -d
#docker-compose.yml
version: '2'
services:
  jenkins:
    image: jenkins-docker:latest
    ports:
      - "8080:8080"
      - "50000:50000"
    networks:
      - jenkins
    volumes:
      - /var/jenkins_home:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
  postgres:
    image: postgres:9.6
    networks:
      - jenkins
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonarpasswd
    volumes:
      - /var/postgres-data:/var/lib/postgresql/data
  sonarqube:
    image: sonarqube:lts
    ports:
      - "9000:9000"
      - "9092:9092"
    networks:
      - jenkins
    environment:
      SONARQUBE_JDBC_USERNAME: sonar
      SONARQUBE_JDBC_PASSWORD: sonarpasswd
      SONARQUBE_JDBC_URL: "jdbc:postgresql://postgres:5432/sonar"
    depends_on:
      - postgres

networks:
  jenkins:
  • 인스턴스 9000번 포트 열어주고 확인해보자 (소나큐브 설치 완료되었는지 확인)

  • Jenkins pipeline을 통해 Sonarqube 통합
  • Sonarqube Scanner for Jenkins 플러그인 설치
    • 이후 Jenkinsfile에 코드 넣어두면 된다! (sonar-scanner 부분)
node {
    def myGradleContainer = docker.image('gradle:jdk8-alpine')
    myGradleContainer.pull()

    stage('prep') {
        git url: 'https://github.com/wardviaene/gs-gradle.git'
    }

    stage('build') {
      myGradleContainer.inside("-v ${env.HOME}/.gradle:/home/gradle/.gradle") {
        sh 'cd complete && /opt/gradle/bin/gradle build'
      }
    }

    stage('sonar-scanner') {
      def sonarqubeScannerHome = tool name: 'sonar', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
      withCredentials([string(credentialsId: 'sonar', variable: 'sonarLogin')]) {
        sh "${sonarqubeScannerHome}/bin/sonar-scanner -e -Dsonar.host.url=http://sonarqube:9000 -Dsonar.login=${sonarLogin} -Dsonar.projectName=gs-gradle -Dsonar.projectVersion=${env.BUILD_NUMBER} -Dsonar.projectKey=GS -Dsonar.sources=complete/src/main/ -Dsonar.tests=complete/src/test/ -Dsonar.language=java -Dsonar.java.binaries=."
      }
    }
}

 

'Computer Science > DevOps' 카테고리의 다른 글

[Monitoring] Monitoring vs Observability  (0) 2025.01.13
[AWS] WEB - WAS 구성 (Apache - Tomcat)  (0) 2023.07.27
[Jenkins] Jenkins Pipeline 구축  (0) 2023.07.03
[Jenkins] Jenkins 다뤄보기  (0) 2023.06.27
[OS] OS 모음집  (0) 2021.08.12

Jenkins 구축 관련해서 아래의 블로그를 참고!

https://realyun99.tistory.com/199


Jekins Pipeline

  • Jenkins를 사용하여 CD Pipeline 을 구현하고 통합하는 것을 지원하는 플러그인의 집합
  • Pipeline DSL 구문을 통해 코드로 전송 파이프라인을 모델링하기 위한 확장 가능한 자동화 서버를 갖추고 있음
  • Jenkinsfile 소스에 해당 내용을 넣고 경로를 보여주면 됨
  • Pipeline에 대한 자세한 내용은 해당 블로그를 참고하면 좋을 듯 싶다!

Jenkins Pipeline 프로젝트 생성

  • project configure

https://github.com/wardviaene/docker-demo 를 내 github으로 fork
해당 docker.build안 docker 주소 본인 환경에 맞게 변경

  • 지금 빌드 클릭

dockerhub 레포지토리에도 이미지 올라간 것을 볼 수 있음!


Docker Pipeline 프로젝트 생성

  • docker pipeline plugin 설치 후 프로젝트 생성

  • project configure

물론 해당 젠킨스 파일 또 잘 수정해야함...

  • 지금 빌드 클릭

dockerhub 에 올라옴!


위의 단계들을 진행하면서 제일 중요한건 Jenkinsfile안의 코드다! 두 프로젝트의 차이점도 Jenkinsfile 밖에 없다.

해당 파일들의 내용을 파헤쳐보자.

 

Jenkinsfile: Jenkins Pipeline ver

node {
   def commit_id
   stage('Preparation') {
     checkout scm
     sh "git rev-parse --short HEAD > .git/commit-id"                        
     commit_id = readFile('.git/commit-id').trim()
   }
   stage('test') {
     nodejs(nodeJSInstallationName: 'nodejs') {
       sh 'npm install --only=dev'
       sh 'npm test'
     }
   }
   stage('docker build/push') {
     docker.withRegistry('https://index.docker.io/v2/', 'dockerhub') {
       def app = docker.build("realyun99/docker-nodejs-demo:${commit_id}", '.').push()
     }
   }
}

Jenkinsfile.v2: Docker Pipeline ver

node {
   def commit_id
   stage('Preparation') {
     checkout scm
     sh "git rev-parse --short HEAD > .git/commit-id"
     commit_id = readFile('.git/commit-id').trim()
   }
   stage('test') {
     def myTestContainer = docker.image('node:16')
     myTestContainer.pull()
     myTestContainer.inside {
       sh 'npm install --only=dev'
       sh 'npm test'
     }
   }
   stage('test with a DB') {
     def mysql = docker.image('mysql').run("-e MYSQL_ALLOW_EMPTY_PASSWORD=yes") 
     def myTestContainer = docker.image('node:16')
     myTestContainer.pull()
     myTestContainer.inside("--link ${mysql.id}:mysql") { // using linking, mysql will be available at host: mysql, port: 3306
          sh 'npm install --only=dev' 
          sh 'npm test'                     
     }                                   
     mysql.stop()
   }                                     
   stage('docker build/push') {            
     docker.withRegistry('https://index.docker.io/v2/', 'dockerhub') {
       def app = docker.build("realyun99/docker-nodejs-demo:${commit_id}", '.').push()
     }                                     
   }                                       
}

 

  • test 단계에서 docker 이미지를 당겨와서 사용할 수 있다 → jenkins configure에서 따로 설정해줄 필요가 없다!
    • 즉 nodejs를 jenkins 컨테이너가 아닌 옆에 새 컨테이너를 생성하고 해당 커멘드들을 실행하게 된다.
    • 커멘드 실행이 끝나면 컨테이너는 폐기되고 다음 단계로 넘어간다.

 

 

❗ 원하는대로 컨테이너 생성해서 이미지 올리는 등의 코드를 작성하고 싶으면 Docker Pipeline이 유용할 듯 싶다? ❗

'Computer Science > DevOps' 카테고리의 다른 글

[AWS] WEB - WAS 구성 (Apache - Tomcat)  (0) 2023.07.27
[Jenkins] 다양한 플러그인 활용  (0) 2023.07.24
[Jenkins] Jenkins 다뤄보기  (0) 2023.06.27
[OS] OS 모음집  (0) 2021.08.12
[CI/CD] Tool  (0) 2021.08.11

+ Recent posts