[OS 버전]
다음과 같이 ubuntu20.04 환경에서 192.168.56.111 호스트ip의 환경에서 작업했습니다.
[Download OpenShift origin]
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
다음 명령어로 OpenShift Origin 을 다운로드 받습니다. 다운로드가 완료되면 다음 명령어로 다운로드한 파일의 압축을 풉니다.
tar -xvzf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
다음으로 디렉터리를 추출된 디렉터리로 변경하고 kubectl 및 oc 바이너리를 /usr/local/bin 디렉터리에 복사합니다.
cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
cp oc kubectl /usr/local/bin/
그 후 다음 명령어를 사용하여 openshift 클라이언트 유틸리티 설치를 확인합니다.
oc version
ㄴ출력은 다음과 같습니다.
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
다음으로 새 daemon.json 파일을 만들고 Insecure Docker 레지스트리 사용을 허용해야 합니다.
sudo vi /etc/docker/daemon.json
다음 줄을 추가합니다.
{
"insecure-registries" : [ "172.30.0.0/16" ]
}
[Start OpenShift origin Cluster]
oc cluster up --public-hostname=192.168.56.111 [your-server-ip]
Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11 is available ...
Pulling image openshift/origin-control-plane:v3.11
Pulled 1/5 layers, 21% complete
Pulled 2/5 layers, 47% complete
Pulled 3/5 layers, 64% complete
Pulled 4/5 layers, 97% complete
Pulled 5/5 layers, 100% complete
Adding default OAuthClient redirect URIs ...
Adding registry ...
Adding sample-templates ...
Adding persistent-volumes ...
Adding web-console ...
Adding centos-imagestreams ...
Adding router ...
penShift server started.
The server is accessible via web console at:
https://192.168.56.111:8443
You are logged in as:
User: developer
Password: <any value>
To login as administrator:
oc login -u system:admin
서버가 성공적으로 시작되면 다음처럼 출력이 표시 됩니다.
이제 다음 명령어를 통해 관리자로 클러스터에 로그인합니다.
oc login -u system:admin
Logged into "https://192.168.56.111:8443" as "system:admin" using existing credentials.
You have access to the following projects and can switch between them with 'oc project <projectname>':
default
kube-dns
kube-proxy
kube-public
kube-system
* myproject
openshift
openshift-apiserver
openshift-controller-manager
openshift-core-operators
openshift-infra
openshift-node
openshift-service-cert-signer
openshift-web-console
oc project default
Now using project "default" on server "https://192.168.56.111:8443".
다음 명령어를 통해 프로젝트의 현재 상태를 확인합니다.
oc status
In project My Project (myproject) on server https://192.168.56.111:8443
다음과 같이 출력됩니다.
[Create Project on openshift]
oc login
Authentication required for https://your-server-ip:8443 (openshift)
Username: developer
Password:
developer로 사용자 이름을 입력하고 Enter 키를 누릅니다. 다음 출력이 표시되어야 합니다.
Login successful.
You have one project on this server: "myproject"
Using project "myproject".
다음으로 새 프로젝트를 생성하는 명령어를 실행시킵니다.
oc new-project dev --display-name="Project - Dev" --description="My Project"
Now using project "dev" on server "https://your-server-ip:8443".
You can add applications to this project with the 'new-app' command. For example, try:
oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
to build a new example application in Ruby.
다음과 같이 출력됩니다.
[Access web console]
웹 브라우저를 열고 https://192.168.56.111:8443/console 를 입력하시면 접근 가능합니다. openshift 로그인 페이지가 표시됩니다.
developer 이름과 암호를 제공하고 로그인 버튼을 클릭합니다. 다음페이지가 표시됩니다.
프로젝트 만들기 버튼을 클릭합니다. 다음 페이지가 출력됩니다.
다음과 같이 구성 후 Create Project를 클릭합니다. 이로서 새 프로젝트 생성이 완료 되었습니다.
[Deploy application on origin OpenShift]
첫번쨰로 openshift에 로그인합니다.
oc login
Authentication required for https://192.168.56.111:8443 (openshift)
Username: developer
Password:
Login successful.
You have access to the following projects and can switch between them with 'oc project ':
* dev
my-project
myproject
Using project "dev".
로그인하면 프로젝트를 OpenShift 웹 콘솔을 통해 생성된 myproject로 전환합니다.
oc project my-project
Now using project "my-project" on server "https://192.168.56.111:8443".
다음 명령어를 사용해서 docker hub 레지스트리의 애플리케이션 이미지에 태그를 지정합니다.
oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest
--> Found image da61bb2 (4 years old) in image stream "my-project/deployment-example" under tag "latest" for "deployment-example"
* This image will be deployed in deployment config "deployment-example"
* Port 8080/tcp will be load balanced by service "deployment-example"
* Other containers can access this service through the hostname "deployment-example"
* WARNING: Image "my-project/deployment-example:latest" runs as the 'root' user which may not be permitted by your cluster administrator
--> Creating resources ...
deploymentconfig.apps.openshift.io "deployment-example" created
service "deployment-example" created
--> Success
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/deployment-example'
Run 'oc status' to view your app.
다음과 같이 출력됩니다.
Service를 확인합니다.
oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
deployment-example ClusterIP 172.30.197.194 <none> 8080/TCP 1h
pod를 확인합니다.
다음 명령으로 외부 액세스를 위해 service를 pod 에 expose 합니다.
oc expose service/deployment-example
route.route.openshift.io/deployment-example exposed
oc get routes
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
deployment-example deployment-example-myproject.192.168.56.111.nip.io deployment-example 8080-tcp None
[외부 액세스를 확인]
이제 application이 외부 액세스를 해봅니다. 웹브라우저를 열고 위 URL
http:// deployment-example-myproject.192.168.56.111.nip.io
를 입력합니다. 다음 페이지에 애플리케이션이 표시됩니다.
댓글