주:

소스에서 Oracle Cloud Native Environment 구축

소개

Oracle Cloud Native Environment(Oracle CNE) CLI(명령행 인터페이스)는 조직에서 Kubernetes 클러스터의 수명 주기를 관리합니다. 또한 GitHub에서 사용할 수 있는 오픈 소스 프로젝트이며 이 자습서에서는 ocne 실행 파일을 직접 빌드하는 방법을 보여줍니다.

Oracle Cloud Native Environment 2에 대한 자세한 내용은 현재 릴리스 문서 사이트를 참조하십시오.

목표

이 자습서에서는 다음 내용을 학습합니다.

필요 조건

Oracle Cloud Native Environment 구성

주: 고유 테넌시에서 실행 중인 경우 랩 환경을 배치하기 전에 linux-virt-labs GitHub 프로젝트 README.md을 읽고 필요 조건을 완료하십시오.

  1. Luna Desktop에서 터미널을 엽니다.

  2. linux-virt-labs GitHub 프로젝트를 복제합니다.

    git clone https://github.com/oracle-devrel/linux-virt-labs.git
    
  3. 작업 디렉토리로 변경합니다.

    cd linux-virt-labs/ocne2
    
  4. 필요한 모음을 설치합니다.

    ansible-galaxy collection install -r requirements.yml
    
  5. lab 환경을 배치합니다.

    ansible-playbook create_instance.yml -e localhost_python_interpreter="/usr/bin/python3.6" -e ocne_type=libvirt
    

    무료 실습 환경에는 추가 변수 local_python_interpreter이 필요합니다. 이 변수는 localhost에서 실행되는 재생에 대해 ansible_python_interpreter를 설정합니다. 환경이 python3.6 모듈 아래에 있는 Oracle Cloud Infrastructure SDK for Python용 RPM 패키지를 설치하므로 이 변수가 필요합니다.

    기본 배치 구성은 AMD CPU 및 Oracle Linux 8을 사용합니다. Intel CPU 또는 Oracle Linux 9를 사용하려면 배치 명령에 -e instance_shape="VM.Standard3.Flex" 또는 -e os_version="9"를 추가합니다.

    중요: 플레이북이 성공적으로 실행될 때까지 기다렸다가 일시 중지 작업에 도달합니다. 이 플레이북 단계에서는 Oracle Cloud Native Environment 설치가 완료되고 인스턴스가 준비됩니다. 배치하는 노드의 공용(public) 및 전용(private) IP 주소와 실습을 실행하는 동안 필요한 기타 배치 정보를 출력하는 이전 플레이를 기록해 둡니다.

필요 조건 설치

  1. 터미널을 열고 SSH를 통해 ocne 인스턴스에 연결합니다.

    ssh oracle@<ip_address_of_instance>
    
  2. Git을 설치합니다.

    sudo dnf install git -y
    
  3. Oracle CNE 저장소를 복제합니다.

    git clone https://github.com/oracle-cne/ocne.git
    
  4. 작업 디렉토리로 변경합니다.

    cd ocne
    
  5. 사용 가능한 Oracle Cloud Native Environment 패키지를 나열합니다.

    sudo dnf search ocne
    

    출력 예:

    [oracle@ocne ~]$ sudo dnf search ocne
    Last metadata expiration check: 0:01:00 ago on Fri 28 Mar 2025 11:48:50 AM GMT.
    ========================================================== Name Matched: ocne ===========================================================
    oracle-ocne-release-el8.src : Oracle Cloud Native Environment yum repository configuration
    oracle-ocne-release-el8.x86_64 : Oracle Cloud Native Environment yum repository configuration
    
  6. 저장소 패키지를 설치합니다.

    Oracle Linux 8

    sudo dnf install -y oracle-ocne-release-el8
    

    Oracle Linux 9

    sudo dnf install -y oracle-ocne-release-el9
    
  7. 저장소를 사용으로 설정합니다.

    Oracle Linux 8

    sudo dnf config-manager --enable ol8_ocne
    

    Oracle Linux 9

    sudo dnf config-manager --enable ol9_ocne
    sudo dnf config-manager --enable ol9_olcne19
    
  8. Codeready 저장소를 사용으로 설정합니다.

    CodeReady 저장소는 개발자가 응용 프로그램을 빌드하고 패키지화할 수 있는 많은 패키지와 도구를 제공합니다.

    Oracle Linux 8

    sudo dnf config-manager --enable ol8_codeready_builder
    

    Oracle Linux 9

    sudo dnf config-manager --enable ol9_codeready_builder
    
  9. 저장소가 사용으로 설정되었는지 확인합니다.

    sudo dnf repolist
    
  10. Oracle Linux 9에 대한 Helm 요구 사항을 업데이트합니다.

    Oracle Linux 8

    필요하지 않습니다.

    Oracle Linux 9

    sed -i 's/3.13.0/3.12.0/' buildrpm/ocne.spec
    
  11. 필요 조건을 설치합니다.

    sudo yum-builddep buildrpm/ocne.spec -y
    

    출력 예:

    [oracle@ocne ocne]$ sudo yum-builddep buildrpm/ocne.spec 
    Oracle Linux 8 BaseOS Latest (x86_64)                                                                    317 kB/s | 4.3 kB     00:00    
    Oracle Linux 8 Application Stream (x86_64)                                                                69 kB/s | 4.5 kB     00:00    
    Oracle Linux 8 CodeReady Builder (x86_64) - Unsupported                                                   39 MB/s |  12 MB     00:00    
    Oracle Linux 8 Addons (x86_64)                                                                           184 kB/s | 3.5 kB     00:00    
    Oracle Cloud Native Environment version 2.0 (x86_64)                                                      30 MB/s | 6.1 MB     00:00    
    Dependencies resolved.
    =========================================================================================================================================
     Package                           Architecture    Version                                          Repository                      Size
    =========================================================================================================================================
    Installing:
     btrfs-progs-devel                 x86_64          5.15.1-2.el8                                     ol8_UEKR7                       49 k
     device-mapper-devel               x86_64          8:1.02.181-15.0.1.el8_10                         ol8_codeready_builder          284 k
     golang                            x86_64          1.22.9-1.module+el8.10.0+90476+bb48cc15          ol8_appstream                  759 k
     gpgme-devel                       x86_64          1.13.1-12.el8                                    ol8_codeready_builder          166 k
     helm                              x86_64          3.17.1-2.el8                                     ol8_ocne                        12 M
     libassuan-devel                   x86_64          2.5.1-3.el8                                      ol8_codeready_builder           69 k
     rpm-build                         x86_64          4.14.3-32.0.1.el8_10                             ol8_appstream                  174 k
     yq                                x86_64          4.45.1-1.el8                                     ol8_ocne                       3.4 M
    Upgrading:
     btrfs-progs                       x86_64          5.15.1-2.el8                                     ol8_UEKR7                      864 k
    ...
    ...
      python3-rpm-macros-3-45.el8.noarch                                  qt5-srpm-macros-5.15.3-1.el8.noarch                                
      redhat-rpm-config-131-1.0.1.el8.noarch                              rpm-build-4.14.3-32.0.1.el8_10.x86_64                              
      rust-srpm-macros-5-2.el8.noarch                                     systemd-devel-239-82.0.3.el8_10.3.x86_64                           
      yq-4.45.1-1.el8.x86_64                                              zstd-1.4.4-1.0.1.el8.x86_64   
    

실행 파일 작성

  1. 사용 가능한 옵션을 확인합니다.

    make
    

    출력 예:

    [oracle@ocne ocne]$ make
    
    Usage:
      make <target>
      help                       Display this help.
      build-cli                  Build CLI for the current system and architecture
      cli                        Build and install the CLI
      clean                      Delete output from prior builds
    
    Linting and coverage
      check                      Run all linters
      check-golangci-lint        Run Go linters
      install-golangci-lint      Install golangci-lint
      word-linter                Check for use of 'bad' words
    
  2. 실행 파일을 작성합니다.

    make build-cli
    

    출력 예:

    [oracle@ocne ocne]$ make cli
    ...
    ...
    cd repo && helm repo index .
    make[1]: Leaving directory '/home/oracle/ocne/build/catalog'
    mkdir -p pkg/catalog/embedded/charts
    cp build/catalog/repo/* pkg/catalog/embedded/charts
    mkdir -p out/linux_amd64
    GOTOOLCHAIN=local GO111MODULE=on GOPRIVATE=github.com/oracle-cne/ocne go build -trimpath -ldflags "-X 'github.com/oracle-cne/ocne/cmd/info.gitCommit=1101a5b5fb72e9812aa14cf68613d28440f1bc57' -X 'github.com/oracle-cne/ocne/cmd/info.buildDate=2025-04-02T09:54:53Z' -X 'github.com/oracle-cne/ocne/cmd/info.cliVersion=2.1.2-3.el8'" -tags developer -o out/linux_amd64 ./...
    
  3. 실행 파일이 있는지 확인합니다.

    ls -al out/linux_amd64/
    

    출력 예:

    [oracle@ocne ocne]$ ls -al out/linux_amd64/
    total 194744
    drwxrwxr-x. 2 oracle oracle        18 Mar 28 12:35 .
    drwxrwxr-x. 3 oracle oracle        25 Mar 28 12:30 ..
    -rwxrwxr-x. 1 oracle oracle 199415168 Mar 28 12:35 ocne
    
  4. 작동하는지 확인합니다.

    out/linux_amd64/ocne info
    

    출력 예:

    [oracle@ocne ocne]$ out/linux_amd64/ocne info
    CLI Info
    Name     	Value                                   
    Version  	2.1.2-3.el8                             
    BuildDate	2025-04-02T09:54:53Z                    
    GitCommit	1101a5b5fb72e9812aa14cf68613d28440f1bc57
    
    Environment Variables
    Name         	Description                                       	Current Value
    OCNE_DEFAULTS	Sets the location of the default configuration    	             
                 	file.                                             	             
    KUBECONFIG   	Sets the location of the kubeconfig file. This    	             
                 	behaves the same way as the --kubeconfig option   	             
                 	for most ocne commands.                           	             
    EDITOR       	Sets the default document editor.
    

    VersionBuildDate 값을 확인합니다. 버전기본의 최신 버전을 반영하며, BuildDateocne 실행 파일을 작성한 날짜 및 시간을 반영합니다.

단일 노드 클러스터 만들기

  1. 단일 노드 Oracle Cloud Native Environment 클러스터를 생성합니다.

    out/linux_amd64/ocne cluster start
    

    시스템의 사용 가능한 리소스에 따라 이미지 소스를 다운로드하고 설정하는 동안 클러스터 만들기를 완료하는 데 몇 분 정도 걸릴 수 있습니다.

    완료되면 y를 입력하여 설치를 완료하고 명령 프롬프트로 돌아갑니다. 사후 설치 단계의 나머지 부분은 무시하고 다음 단계로 진행합니다.

    출력 예:

    Run the following command to create an authentication token to access the UI:
        KUBECONFIG='/home/oracle/.kube/kubeconfig.ocne.local' kubectl create token ui -n ocne-system
    Browser window opened, enter 'y' when ready to exit: y
    
    INFO[2025-03-28T13:10:04Z] Post install information:
    
    To access the cluster from the VM host:
        copy /home/oracle/.kube/kubeconfig.ocne.vm to that host and run kubectl there
    To access the cluster from this system:
        use /home/oracle/.kube/kubeconfig.ocne.local
    To access the UI, first do kubectl port-forward to allow the browser to access the UI.
    Run the following command, then access the UI from the browser using via https://localhost:8443
        kubectl port-forward -n ocne-system service/ui 8443:443
    Run the following command to create an authentication token to access the UI:
        kubectl create token ui -n ocne-system
    
  2. Kubernetes 명령행 도구(kubectl) 설치

    sudo dnf install -y kubectl
    
  3. 새로 만든 클러스터를 사용하도록 kubectl을 구성합니다.

    export KUBECONFIG=$HOME/.kube/kubeconfig.ocne.local
    
  4. 클러스터가 하나의 노드로만 구성되는지 확인합니다.

    kubectl get nodes --all-namespaces
    

    출력 예:

    [oracle@ocne ~]$ kubectl get nodes --all-namespaces
    NAME                   STATUS   ROLES           AGE     VERSION
    ocne-control-plane-1   Ready    control-plane   2m23s   v1.31.6+1.el8
    
  5. 클러스터가 성공적으로 배치되었는지 확인합니다.

    kubectl get deployments --all-namespaces
    

    출력 예:

    [oracle@ocne ~]$ kubectl get deployments --all-namespaces
    NAMESPACE     NAME           READY   UP-TO-DATE   AVAILABLE   AGE
    kube-system   coredns        2/2     2            2           15m
    ocne-system   ocne-catalog   1/1     1            1           15m
    ocne-system   ui             1/1     1            1           15m
    
  6. 배치된 모든 Pod를 나열합니다.

    kubectl get pods --all-namespaces
    

    출력 예:

    [oracle@ocne ~]$ kubectl get pods --all-namespaces
    NAMESPACE      NAME                                           READY   STATUS    RESTARTS      AGE
    kube-flannel   kube-flannel-ds-8fbm2                          1/1     Running   0.            13m
    kube-system    coredns-f7d444b54-njk46                        1/1     Running   0             13m
    kube-system    coredns-f7d444b54-xn975                        1/1     Running   0             13m
    kube-system    etcd-ocne-control-plane-1                      1/1     Running   0             13m
    kube-system    kube-apiserver-ocne-control-plane-1            1/1     Running   0             13m
    kube-system    kube-controller-manager-ocne-control-plane-1   1/1     Running   0             13m
    kube-system    kube-proxy-jsfqs                               1/1     Running   0             13m
    kube-system    kube-scheduler-ocne-control-plane-1            1/1     Running   0             13m
    ocne-system    ocne-catalog-578c959566-75rr5                  1/1     Running   0             13m
    ocne-system    ui-84dd57ff69-grxlk                            1/1     Running   0             13m
    

    이 출력은 소스 코드에서 ocne를 성공적으로 빌드하고 새 Kubernetes 클러스터를 생성했음을 확인합니다.

다음 단계

이 사용지침서에서는 로컬 테스트에 유용한 GitHub의 소스 코드에서 Oracle CNE CLI를 빌드하는 방법을 보여줍니다. 그러나 이것은 단지 시작일 뿐입니다. 추가 자습서 및 컨텐츠는 Oracle Linux Training Station을 확인해 보십시오.

추가 학습 자원

docs.oracle.com/learn에서 다른 실습을 탐색하거나 Oracle Learning YouTube 채널에서 더 많은 무료 학습 콘텐츠에 액세스하세요. 또한 Oracle Learning Explorer가 되려면 education.oracle.com/learning-explorer을 방문하십시오.

제품 설명서는 Oracle Help Center를 참조하십시오.