openshift

 

What is OpenShift?


OpenShift는 Platform as a Service 환경을 제공 해주는 RedHat의 솔루션 입니다.
Platform as a Service(PaaS)란 응용프로그램(Appllication)을 개발하기 위한 안정적인 환경을 제공 하는 형태를 말합니다.
즉, 사용자가 직접 구축 할 필요 없이 ‘이미 구축 되어 있는 것을 바로 가져다 사용 또는 개발 할 수 있도록 환경을 제공 하는 것’이라 이해 하시면 됩니다.

OpenShift는 4가지 버전으로 나뉩니다.

– Origin

오픈소스로 제공 하는 버전 입니다.

– Enterprise
Origin Stable 버전이 Enterprise 입니다.

– Online
온라인에서 바로 사용 할 수 있도록 만들어진 무료/유료 서비스 입니다.

– Dedicated
클라우드 서버에서 OpenShift를 단독으로 제공 해주는 서비스 입니다.

여기서, Origin과 Enterprise가 어떤 부분에서 차이가 있는지 궁금 하실텐데요..
제가 아는 바로는 설정 부분에서 미묘한 차이가 존재 하는 것 뿐이지 별반 차이 없다고 느꼈습니다.
(제가 RedHat 직원이 아니기 때문에 자세한건 모르겠네요. ㅋㅋ)

그럼, OpenShift에 어떻게 구성 되어 있고 어떻게 사용하는지 실제 구축을 통해 알아 보도록 하겠습니다.

본 글은 OpenShift Origin v3.x 기반에서 테스트 되었으며, 작성자의 지극히 개인적인 경험을 바탕으로 작성한 내용 입니다.
따라서, 틀린 부분이 존재 할 수 있으므로 이점 감안하여 읽어 주시기 바라며, 지적 사항이나 궁금한 사항이 있다면 댓글 달아 주세요. 🙂

 

OpenShift Architecture


OpenShift v3.x에서는 아래의 Docker, Kubernetes, Mesos의 주요 모델을 기반으로 몇가지 필요한 추가 사항들을 반영하여 만들어졌다고 보면 되겠습니다.

– 3가지 주요 모델

Docker : Docker Registry
Kubernetes : Container Management
Apache Mesos : Scheduling and execution framework

그럼, OpenShift가 어떤 부분으로 구성 되어 있는지 살펴 보도록 하겠습니다.

 

– Master

* OpenShift Web Console
관리자 및 개발자가 웹에서 접근을 하고, 프로젝트를 생성 할 수 있도록 제공 해주는 Web UI 입니다.

* OpenShift APIs
인증 및 프로젝트, Kubernetes 관한 API를 제공 해줍니다.

* Software Defined Network
내부, 외부 통신을 위해 소프트웨어 정의 네트워크로 Open vSwitch가 사용 됩니다.


– Minion

* Docker Registry
Docker Container의 내부 이미지 저장소 입니다.
사용자가 생성한 프로젝트의 Appilcation이 빌드가 완료 되면, 해당 이미지가 내부 이미지 저장소로 업로드 됩니다.

* Router
Pod의 Container를 위한 Load Balancing용 프록시 서버 및 서브 도메인 등록 서버 입니다.

* Software Defined Network
내부, 외부 통신을 위해 소프트웨어 정의 네트워크로 Open vSwitch가 사용 됩니다.

 

– Command

* oc
oc 명령어는 Kubernetes의 kubectl에 OpenShift에 필요한 명령어를 합친 것이라 보면 됩니다.
이 명령어를 통해 node, pod, service, replica, template, project 등등의 정보를 확인 할 수 있습니다.

* oadm
클러스터를 관리하기 위한 명령어 입니다.
command-line으로 새로운 프로젝트를 생성하고 정책 및 그룹을 지정 할 수 있으며,
새로운 노드를 추가 하거나 유지보수를 위한 고급 명령어들을 사용 가능 합니다.

 

– Other

* DNS
Application에 DNS를 연결 하여 외부로 접근이 용이 하도록 사용 됩니다.
프로젝트에서 Application을 실행 했을 경우 외부에서 접속이 가능 하도록 도메인을 연결 해줄 때 사용 합니다.

* HAProxy
Master와 Minion에서 Fault Tolerance 또는 Load Balancing, Virtual IP 용도로 사용 합니다.
Master 서버를 3대 이상으로 구성할 경우 Web Console을 하나의 도메인 또는 VIP를 가지고 접근 할 수 있도록 해주거나,
장애 발생시 문제 없이 서비스를 지속적으로 제공 해주기 위한 용도로 사용 될 수 있습니다.

* atomic-openshift-installer (Ansible) 
OpenShift를 실제로 배포하기 위한 자동화 배포 도구 입니다. (다들 아시는 Ansible을 사용 합니다.)
SSH Key를 기반으로 배포하기 때문에, 구성할 서버에 미리 SSH Key 설정이 되어 있어야 합니다.


openshift_v3.x_architectureFigure 1. OpenShift Architecture

 

OpenShift Origin (All Node)


Fully distributed 환경으로 만들어 보고자 합니다.
대략 10대 정도의 서버가 필요 합니다. (DNS 서버를 구성하지 않으시겠다면, 9개로 구성 하시면 되겠습니다.)

Deploy   - 1EA
DNS      - 1EA
HAProxy  - 1EA
Router   - 1EA
Master   - 3EA
Minion   - 3EA
---------------
Total:     10EA

Deploy 서버는 OpenShift를 구성하려는 서버에 설정 및 설치 부분에 대해 배포하기 위해 사용 됩니다.
따라서, 모든 구성은 Deploy 서버에서 진행 하며, 따로 언급이 없는 경우에는 배포 서버에서 설정 한다고 보시면 되겠습니다.

각 서버에서 접근 및 설정이 용이 하도록 공통적으로 설정 되야 하는 부분에 대해서 먼저 설정 하도록 하겠습니다.

 

1. Hosts 등록
OpenShift가 설치 되고 설정 되어야할 서버들의 호스트 네임 정보를 deploy 서버에 추가 합니다.

[root@deploy ~]# cat << EOF >> /etc/hosts
# OpenShift Hosts
192.168.103.120   deploy       deploy.openshift.yongbok.net
192.168.103.121   dns                       dns.yongbok.net
192.168.103.122   openshift           openshift.yongbok.net
192.168.103.123   master01   master01.openshift.yongbok.net
192.168.103.124   master02   master02.openshift.yongbok.net
192.168.103.125   master03   master03.openshift.yongbok.net
192.168.103.126   router       router.openshift.yongbok.net
192.168.103.127   minion01   minion01.openshift.yongbok.net
192.168.103.128   minion02   minion02.openshift.yongbok.net
192.168.103.129   minion03   minion03.openshift.yongbok.net
EOF

 

2. NTP 설정
각 서버의 시간을 동일하게 맞추기 위한 설정 입니다.
(폐쇠망을 운영하는 경우 외부로 접근이 되는 NTP 서버를 따로 두고 로컬 NTP로 구성 하시는 편이 좋습니다.)

[root@deploy ~]# yum install -y chrony
[root@deploy ~]# for i in {0..3}; do
  sed -i "s/$i.centos.pool.ntp.org iburst/$i.asia.pool.ntp.org iburst/g" /etc/chrony.conf
done

 

3. OpenSSH 설정
SSH 접속시 호스트의 SSH 접속 key를 확인 하는 부분을 비활성 합니다. (테스트 용도니까 귀찮은건 제외 합시다.)

[root@deploy ~]# sed -i 's/# StrictHostKeyChecking ask/ StrictHostKeyChecking no/g' /etc/ssh/ssh_config

 

4. SSH Key 생성
각 서버를 제어하기 위해 SSH Key를 생성 합니다.

[root@deploy ~]# ssh_key_dir="/root/.ssh"
[root@deploy ~]# ssh-keygen -f $ssh_key_dir/id_rsa -N ''
[root@deploy ~]# cat $ssh_key_dir/id_rsa.pub > $ssh_key_dir/authorized_keys

 

5. SSH Key 배포
최초 SSH Key를 배포하기 위해 sshpass를 사용하여 배포 하도록 합니다.
sshpass를 사용하기 위해서는 외부 저장소인 EPEL을 추가 하여야 합니다.

[root@deploy ~]# yum install -y epel-release
[root@deploy ~]# yum install -y sshpass
[root@deploy ~]# NODE_PWD="openshift"
[root@deploy ~]# for node in {dns,openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  echo "Deploy SSH Key on $node" && \
  sshpass -p $NODE_PWD ssh-copy-id root@$node
  sshpass -p $NODE_PWD scp $ssh_key_dir/id_rsa root@$node:$ssh_key_dir
  sshpass -p $NODE_PWD scp $ssh_key_dir/authorized_keys root@$node:$ssh_key_dir
  sshpass -p $NODE_PWD scp /etc/ssh/ssh_config root@$node:/etc/ssh;
done

 

6. hosts 및 NTP 설정
앞서 설정하였던 hosts 파일과 NTP 파일을 각 서버에 배포 하여 동기화를 진행 합니다.

[root@deploy ~]# for node in {dns,openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "yum install -y chrony && systemctl enable chronyd"
  scp /etc/hosts root@$node:/etc
  scp /etc/chrony.conf root@$node:/etc
  ssh root@$node "systemctl restart chronyd";
done

 

7. SELinux 활성화
OpenShift는 SELinux가 활성화 되어야 설치가 되므로 활성화 합니다. (기본적으로 enforcing 모드로 지정 되어 있습니다.)

[root@deploy ~]# for node in {dns,openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "sed -i '/^SELINUX=/ s:.*:SELINUX=enforcing:' /etc/sysconfig/selinux";
done

 

8. Bash Completion 패키지 설치
명령어 입력시 수작업으로 입력 하는 것을 줄이고자 Bash Completion 패키지를 설치 합니다. (반드시 필요한 작업은 아닙니다.)

[root@deploy ~]# for node in {dns,openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "yum install -y bash-completion";
done

 

9. Network Manager 제거
Static IP를 사용할 계획이라 불필요한 Network Manager를 삭제 합니다.

[root@deploy ~]# for node in {dns,openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "yum remove -y NetworkManager*";
done

 

10. Docker 설치 및 재시작
실제로 OpenShift를 실행하려면 Master, Minion, Router 서버에 Docker가 설치 되어 있어야 합니다.
나중에 아시겠지만, 앞서 언급한 3개 서버에서는 Container 형태로 배포하여 관리 하기 때문에 필요 합니다.

따라서, DNS 서버를 제외한 나머지 서버들에 대해서는 Docker를 설치 합니다.
(Docker 설치시 EPEL 저장소가 필요 합니다.)

또한, RHEL/CentOS 계열의 Docker Storage Driver는 Device Mapper Driver를 사용하는 것을 권장합니다.
(overlay 등을 사용 하셔도 되나, Docker image 빌드가 안된다거나 하는 문제가 조금 있습니다.)

[root@deploy ~]# for node in {openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum install -y docker && \
  sed -i \"/^OPTIONS=/ s:.*:OPTIONS=\'--selinux-enabled --insecure-registry 172.30.0.0\/16\':\" /etc/sysconfig/docker && \
  sed -i 's/DOCKER_STORAGE_OPTIONS=/DOCKER_STORAGE_OPTIONS=--storage-driver devicemapper/g' /etc/sysconfig/docker-storage && \
  rm -rf /var/lib/docker && systemctl enable docker && reboot";
done

 

OpenShift Origin (DNS Node)


DNS 서버에서만 설정하는 부분이며, 이 작업은 프로젝트에서 생성한 Application에 외부에서 접근이 용이 하도록 서브 도메인을 제공 해주기 위한 용도로 설정 합니다.

본 설정은 실제 도메인을 가지고 있고 이것을 사용하겠다라는 전재하에 진행 합니다.
(실제 IP를 입력 하시면 되겠습니다. 테스트 용도면 내부 IP로 사용하면 됩니다.)

[root@deploy ~]# domain="yongbok.net"
[root@deploy ~]# dns_ip="192.168.103.121"
[root@deploy ~]# router_ip="192.168.103.126"
[root@deploy ~]# serial_date="$(date +%Y%m%d%H)"

 

1. zone 파일 생성
‘*’가 붙은 A 레코드는 도메인 “yongbok.net”에 설정 되어 있는 A 레코드를 제외한
모든 2차 도메인은 router ip 로 설정 하도록 합니다.

이렇게 하는 이유는 프로젝트에서 Application을 배포했을때, router 서버가 Default DNS를 기반으로 서브 도메인 형식으로 배포 하기 때문 입니다.
(이 부분은 뒷 부분에서 몇번 사용하다 보면 이해 됩니다.)

[root@deploy ~]# echo "\$TTL 1
@    IN    SOA    ${domain}. ruo91.${domain}. (
                      ${serial_date}      ; Serial
                      60              ; Refresh
                      15              ; Retry
                      1800            ; Expire
                      10              ; Negative Cache TTL
)
; Name Server
                IN   NS    ${domain}.

;
; Records
; ${dns_ip}: DNS IP
; ${router_ip}: Router ip
                      100    IN    A    ${dns_ip}
*.openshift           100    IN    A    ${router_ip}
openshift             100    IN    A    192.168.103.122
master01.openshift    100    IN    A    192.168.103.123
master02.openshift    100    IN    A    192.168.103.124
master03.openshift    100    IN    A    192.168.103.125
router.openshift      100    IN    A    192.168.103.126
minion01.openshift    100    IN    A    192.168.103.127
minion02.openshift    100    IN    A    192.168.103.128
minion03.openshift    100    IN    A    192.168.103.129

" > /tmp/$domain.db

 

2. named.conf 설정
DNS의 레코드 정보는 보이지 않도록 하면서, Cache DNS 서버로 활용 하도록 설정 합니다.

[root@deploy ~]# echo "options {
// zone 파일이 위치하고 있는 경로를 지정 합니다.
directory \"/var/named\";

// NXDOMAIN으로 응답 여부 (기본값 no)
auth-nxdomain no;

// listen all
listen-on { any; };

// IPv6
listen-on-v6 { no; };

// BIND 버전을 강제로 지정합니다.
version \"${domain}\";

// 자체 네임서버를 사용할 경우 허용할 아이피 또는 대역을 설정합니다.
allow-recursion { any; };

// 네임서버의 zone data 정보를 남에게 보여줄 껀지 여부입니다.
allow-transfer { 127.0.0.1; };

// 자체 네임서버도 사용안하며 OpenDNS를 사용하지 않으려면 주석 해제 하세요.
// 단, allow-recursion는 주석처리 하셔야 합니다.
//recursion no;

// Path to ISC DLV key
bindkeys-file \"/etc/named.iscdlv.key\";
};

// rndc key
include \"/etc/rndc.key\";

controls {
    inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { \"rndc-key\"; };
};

// Loging
logging {
    channel default_debug {
        file \"data/named.run\";
        severity dynamic;
    };
};

// root 도메인의 정보를 가지고 있는 파일을 지정 해줍니다.
zone \".\" {
    type hint;
    file \"named.ca\";
};

// 네임 서버로 사용할 도메인을 지정 해줍니다.
zone \"${domain}\" IN {
    type master;
    allow-update { key ${domain} ; } ;
    file \"zones/${domain}.db\";
};

" > /tmp/named.conf

 

3. DNS 설정 파일 복사 및 Bind 데몬 실행
위의 설정한 Zonefile, named.conf 파일을 DNS 서버로 배포 후 Bind 데몬을 실행 합니다.

[root@deploy ~]# for node in dns; do
  ssh root@$node "yum install -y bind bind-utils && mkdir /var/named/zones"
  scp /tmp/named.conf root@$node:/etc/named.conf
  scp /tmp/$domain.db root@$node:/var/named/zones
  ssh root@$node "chgrp named -R /var/named && \
  chown named -Rv /var/named/zones && \
  restorecon -Rv /var/named && \
  chown -v root:named /etc/named.conf && \
  restorecon -v /etc/named.conf && \
  systemctl enable named && \
  systemctl start named";
done

 

OpenShift Origin (Deploy Node)


실제로 각 서버에 OpenShift를 설치 및 설정을 하기 위해 ‘atomic-openshift-installer’이라는 명령어를 통해 작업 하는데,
이것은 ‘openshift-ansible’이라는 이름의 프로젝트를 github에서 받아 빌드를 해야 사용 가능 합니다.
(Enterprise 버전은 서브스크립션에 포함이 되어 있지만, Origin은 직잡 빌드 해서 설치 해야 합니다.)

그리고, ‘atomic-openshift-installer’ 명령어는 Ansible을 사용하여 배포하는데, ansible을 EPEL 저장소에서 설치 하면 2.x 버전이 설치 됩니다.

사용 하는데 문제는 없지만, 실제로 ‘atomic-openshift-installer’ 명령어를 통해 설치 작업을 하면,
00_openshift 라는 모듈이 없다고 나오므로, ansible 1.9 버전을 설치하는 것을 권장 하는 바입니다.

 

1. Openshift Ansible 설치

[root@deploy ~]# yum install -y gcc git ansible1.9 tito pyOpenSSL python-cryptography
[root@deploy ~]# git clone https://github.com/openshift/openshift-ansible.git /opt/openshift-ansible
[root@deploy ~]# cd /opt/openshift-ansible
[root@deploy ~]# tito build --rpm
[root@deploy ~]# cd /tmp/tito/noarch
[root@deploy ~]# yum install -y *.rpm

이제 각 서버에 OpenShift를 설치하기 위해 ‘atomic-openshift-installer’ 명령어를 실행할 차례 입니다.
진행 하기 위해 ‘y’를 누릅니다.

[root@deploy ~]# atomic-openshift-installer -v install
Welcome to the OpenShift Enterprise 3 installation.

Please confirm that following prerequisites have been met:

* All systems where OpenShift will be installed are running Red Hat Enterprise
  Linux 7.
* All systems are properly subscribed to the required OpenShift Enterprise 3
  repositories.
* All systems have run docker-storage-setup (part of the Red Hat docker RPM).
* All systems have working DNS that resolves not only from the perspective of
  the installer but also from within the cluster.

When the process completes you will have a default configuration for Masters
and Nodes.  For ongoing environment maintenance it's recommended that the
official Ansible playbooks be used.

For more information on installation prerequisites please see:
https://docs.openshift.com/enterprise/latest/admin_guide/install/prerequisites.html

Are you ready to continue? [y/N]: y

 

SSH 접근에 사용할 사용자를 지정 하는 부분 입니다. ‘root’ 사용자로 설정 합니다.

This installation process will involve connecting to remote hosts via ssh. Any
account may be used however if a non-root account is used it must have
passwordless sudo access.

User for ssh access [root]: root

 

OpenShift 버전을 어떤 것으로 설치 할건지 선택 하는 부분 입니다.
최신 버전인 OpenShift Enterprise 3.2를 선택 합니다.
(말이 Enterprise 뿐이지 실제로는 설정 파일의 수정을 통해 Origin으로 변경 해야 합니다.)

Which variant would you like to install?

(1) OpenShift Enterprise 3.2
(2) OpenShift Enterprise 3.1
(3) OpenShift Enterprise 3.0
(4) Atomic Enterprise Platform 3.2
(5) Atomic Enterprise Platform 3.1

Choose a variant from above: [1]: 1

 

호스트 서버를 등록 하는 부분 입니다.
Master 서버 3대로 구성 할 것이니 아래와 같이 Master 서버의 도메인명을 적어 줍니다.

*** Host Configuration ***

You must now specify the hosts that will compose your OpenShift cluster.

Please enter an IP or hostname to connect to for each system in the cluster.
You will then be prompted to identify what role you would like this system to
serve in the cluster.

OpenShift Masters serve the API and web console and coordinate the jobs to run
across the environment.  If desired you can specify multiple Master systems for
an HA deployment, in which case you will be prompted to identify a *separate*
system to act as the load balancer for your cluster after all Masters and Nodes
are defined.

If only one Master is specified, an etcd instance embedded within the OpenShift
Master service will be used as the datastore.  This can be later replaced with a
separate etcd instance if desired.  If multiple Masters are specified, a
separate etcd cluster will be configured with each Master serving as a member.

Any Masters configured as part of this installation process will also be
configured as Nodes.  This is so that the Master will be able to proxy to Pods
from the API.  By default this Node will be unschedulable but this can be changed
after installation with 'oadm manage-node'.

OpenShift Nodes provide the runtime environments for containers.  They will
host the required services to be managed by the Master.

http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#master
http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#node
    
Enter hostname or IP address: master01.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: y
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm

 

Master 서버 1대를 등록 하면 아래와 같이 Summary가 표시 됩니다.

*** Installation Summary ***

Hosts:
- master01.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node
  - Etcd (Embedded)

Total OpenShift Masters: 1
Total OpenShift Nodes: 1

NOTE: Add a total of 3 or more Masters to perform an HA installation.

 

위와 같이 Master 서버를 2대 더 추가 해줍니다.

Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: master02.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: y
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm
Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: master03.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: y
Will this host be RPM or Container based (rpm/container)? [rpm]:

 

Master 3대가 추가 되었습니다.

*** Installation Summary ***

Hosts:
- master01.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node
  - Etcd Member2. openshift-server 배포
- master02.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node
  - Etcd Member
- master03.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node
  - Etcd Member

Total OpenShift Masters: 3
Total OpenShift Nodes: 3

NOTE: Multiple Masters specified, this will be an HA deployment with a separate
etcd cluster. You will be prompted to provide the FQDN of a load balancer and
a host for storage once finished entering hosts.


WARNING: Dedicated Nodes are recommended for an HA deployment. If no dedicated
Nodes are specified, each configured Master will be marked as a schedulable Node.

 

이제 Router 1대, Minion 3대를 위와 같은 방법으로 추가 하되,
Master 서버로 지정 할 것이 아니기 때문에 OpenShift Master 물음에는 ‘n’로 답 해주시기 바랍니다.

Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: router.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: n
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm
Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: minion01.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: n
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm
Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: minion02.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: n
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm
Do you want to add additional hosts? [y/N]: y
Enter hostname or IP address: minion03.openshift.yongbok.net
Will this host be an OpenShift Master? [y/N]: n
Will this host be RPM or Container based (rpm/container)? [rpm]: rpm

 

이쯤에서 정리 해보자면 Master 3대, Router 1대, Minion 3대 = 총 7대 됩니다.

*** Installation Summary ***

Hosts:
- master01.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
- master02.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
- master03.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
- router.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion01.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion02.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion03.openshift.yongbok.net
  - OpenShift Node (Dedicated)

Total OpenShift Masters: 3
Total OpenShift Nodes: 7

NOTE: Multiple Masters specified, this will be an HA deployment with a separate
etcd cluster. You will be prompted to provide the FQDN of a load balancer and
a host for storage once finished entering hosts.

 

더 이상 추가 할 것은 없으니 ‘n’으로 답 합니다.

Do you want to add additional hosts? [y/N]: n

 

Master 서버의 HA 구성을 위한 부분 입니다.
장애가 발생해도 Fault Tolerance로 동작하기 때문에, 하나만 바라 보면 되는 대표 도메인 또는 VIP를 지정 후 HAProxy 설치에 ‘ y’로 답 합니다.

Setting up High Availability Masters requires a load balancing solution.
Please provide a the FQDN of a host that will be configured as a proxy. This
can be either an existing load balancer configured to balance all masters on
port 8443 or a new host that will have HAProxy installed on it.

If the host provided does is not yet configured, a reference haproxy load
balancer will be installed.  It's important to note that while the rest of the
environment will be fault tolerant this reference load balancer will not be.
It can be replaced post-installation with a load balancer with the same hostname.

Enter hostname or IP address: openshift.yongbok.net
Should the reference haproxy load balancer be installed on this host? [y/N]: y

 

HA를 사용할 경우 별도의 HA용 스토리지 호스트가 필요 합니다.
Base가 되는 호스트를 지정 하면 되며, 기본적으로 우선 순위가 높은 놈이 자동으로 지정 됩니다.

Setting up High Availability Masters requires a storage host. Please provide a
host that will be configured as a Registry Storage.

Note: Containerized storage hosts are not currently supported.

Enter hostname or IP address [master01.openshift.yongbok.net]:

 

Router가 기본적으로 가지는 서브 도메인을 지정 해주는 부분 입니다.
이 부분은 프로젝트에서 Application을 배포 했을때 외부에서 접속이 가능 하도록 Router 서버가 서브 도메인을 자동으로 부여 해줄때 필요 합니다.
(위의 DNS 서버 설정 부분에서 나머지 A 레코드를 ‘*’로 사용하였기 때문에 2차 이상의 도메인은 모두 router 서버 IP를 바라보게 되어 있습니다.)

You might want to override the default subdomain uses for exposed routes. If you don't know what
this is, use the default value.

New default subdomain (ENTER for none) []: app.openshift.yongbok.net

 

내부에서 프록시 서버를 사용하고 있는 환경이라면 지정 해주시면 됩니다. 사용하지 않고 있다면, Enter를 눌러 넘기면 됩니다.

If a proxy is needed to reach HTTP and HTTPS traffic please enter the name below.
This proxy will be configured by default for all processes needing to reach systems outside the cluster.

More advanced configuration is possible if using ansible directly:

https://docs.openshift.com/enterprise/latest/install_config/http_proxies.html

Specify your http proxy ? (ENTER for none) []: 
Specify your https proxy ? (ENTER for none) []:

 

설정이 완료 되면 이때 까지 설정한 내용이 간략하게 출력이 됨과 동시에, Host들의 정보를 Gathering 하는 작업이 진행 됩니다.

*** Installation Summary ***

Hosts:
- master01.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
  - Storage
- master02.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
- master03.openshift.yongbok.net
  - OpenShift Master
  - OpenShift Node (Unscheduled)
  - Etcd Member
- router.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion01.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion02.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- minion03.openshift.yongbok.net
  - OpenShift Node (Dedicated)
- openshift.yongbok.net
  - Load Balancer (HAProxy)

Total OpenShift Masters: 3
Total OpenShift Nodes: 7

NOTE: Multiple Masters specified, this will be an HA deployment with a separate
etcd cluster. You will be prompted to provide the FQDN of a load balancer and
a host for storage once finished entering hosts.


Gathering information from hosts...

 

Gathering이 완료 되고 나면 각 서버들의 정보를 출력한 후 해당 정보가 맞는지 다시 한번 확인 하는 부분이 나타납니다.
‘y’를 입력하여 답해 주세요.

master01.openshift.yongbok.net,192.168.103.123,192.168.103.123,master01.openshift.yongbok.net,master01.openshift.yongbok.net
master02.openshift.yongbok.net,192.168.103.124,192.168.103.124,master02.openshift.yongbok.net,master02.openshift.yongbok.net
master03.openshift.yongbok.net,192.168.103.125,192.168.103.125,master03.openshift.yongbok.net,master03.openshift.yongbok.net
router.openshift.yongbok.net,192.168.103.126,192.168.103.126,router.openshift.yongbok.net,router.openshift.yongbok.net
minion01.openshift.yongbok.net,192.168.103.127,192.168.103.127,minion01.openshift.yongbok.net,minion01.openshift.yongbok.net
minion02.openshift.yongbok.net,192.168.103.128,192.168.103.128,minion02.openshift.yongbok.net,minion02.openshift.yongbok.net
minion03.openshift.yongbok.net,192.168.103.129,192.168.103.129,minion03.openshift.yongbok.net,minion03.openshift.yongbok.net
openshift.yongbok.net,192.168.103.122,192.168.103.122,openshift.yongbok.net,openshift.yongbok.net

Format:

connect_to,IP,public IP,hostname,public hostname

Notes:
 * The installation host is the hostname from the installer's perspective.
 * The IP of the host should be the internal IP of the instance.
 * The public IP should be the externally accessible IP associated with the instance
 * The hostname should resolve to the internal IP from the instances
   themselves.
 * The public hostname should resolve to the external ip from hosts outside of
   the cloud.

Do the above facts look correct? [y/N]:

 

설정 정보 확인 후 ‘atomic-openshift-installer’ 설정파일과 ‘ansible inventory’ 파일이 root 계정의 ‘.config/openshift’ 디렉토리에 생성이 됩니다.

Wrote atomic-openshift-installer config: /root/.config/openshift/installer.cfg.yml
Wrote ansible inventory: /root/.config/openshift/hosts

Ready to run installation process.

If changes are needed please edit the config file above and re-run.

Are you ready to continue? [y/N]:

 

여기서 하던 것을 멈추시고,  ‘ansible inventory’ 파일인 ‘/root/.config/openshift/hosts’ 파일을 에디터로 열어 아래와 같이 추가 해주셔야 설치가 정상적으로 됩니다.

[OSEv3:children]
masters
nodes
etcd
lb
nfs

[OSEv3:vars]
ansible_ssh_user=root
# Master 서버의 dnsmasq를 사용하지 않습니다.
# dnsmasq는 아직 v3.2 버전에서 구현이 되지 않는 부분이라 비활성화 시켜야 합니다.
# 이 문제가 개선 되면 이 부분은 주석 처리 하셔도 됩니다.
openshift_use_dnsmasq=False

# 클러스터 구성
# 기본값은 native이며, HAProxy로 HA 구성을 합니다.
# 다른 값으로는 pacemaker가 있으며, pacemaker로 HA 구성을 합니다.
openshift_master_cluster_method=native

# 클러스터 대표 도메인
# 3개로 구성 된 마스터 서버를 클러스터로 묶었을때
# 대표적으로 사용될 도메인을 지정하는 부분 입니다.
openshift_master_cluster_hostname=openshift.yongbok.net
openshift_master_cluster_public_hostname=openshift.yongbok.net

# 서브 도메인
# 프로젝트를 생성 하고 어플리케이션을 생성 했을때
# 실제로 외부에서 해당 어플리케이션에 접속을 위한 서브 도메인을 지정해주는 부분입니다.
# 예를들어 프로젝트명이 'ruo91-project'이고 어플리케이션 이름이 'nodjs'라 했을 경우
# 'nodejs-ruo91-project.app.openshift.yongbok.net'으로 만들어 집니다.
openshift_master_default_subdomain=app.openshift.yongbok.net

# OpenShift 설치 버전
# 설치에 사용 될 버전 입니다.
# 기본값은 openshift-enterprise 이며,
# Origin 버전을 설치하기 위해서는 type을 origin으로 변경 해줘야 합니다.
#deployment_type=openshift-enterprise
deployment_type=origin

# Web Console 인증
# Web console에서 사용할 인증 방식을 지정 하는 부분 입니다.
# 사용자 계정을 Apache의 htpasswd로 사용 하도록 설정 하는 부분 입니다.
# 기본값은 DenyAllPasswordIdentityProvider 이며, 기본값으로 사용시 로그인 자체가 되지 않습니다.
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/openshift-passwd'}]

# 기본 노드 지정
# 프로젝트에서 생성 한 어플리케이션을 배포 했을때
# 실제로 Pod가 실행 될 노드를 지정 하는 부분 입니다.
osm_default_node_selector=region=primary

# Master 서비스 포트 지정
# API, Web Console의 서비스 포트를 지정 합니다.
# 기본값은 8443이며, 편의를 위해 443으로 변경 합니다.
openshift_master_api_port=443
openshift_master_console_port=443

# Router selector
# 라우터를 지정 하는 부분 입니다.
openshift_hosted_router_selector='region=infra'

# Registry selector
# Docker registry 저장소를 지정 하는 부분 입니다.
openshift_registry_selector='region=infra'

# Storage
# 외부 스토리지를 사용할 플러그인을 지정하는 부분 입니다. 
# 지원 되는 플러그인으로는 ceph, glusterfs, iscsi, nfs 정도가 있습니다.
# 단일 또는 복수개로 지정이 가능하며, 이것을 지정 해줬을시 관련 패키지가 설치 됩니다.
#osn_storage_plugin_deps=['ceph','glusterfs','iscsi']
osn_storage_plugin_deps=['iscsi']

[masters]
master01.openshift.yongbok.net  openshift_ip=192.168.103.123 openshift_public_ip=192.168.103.123 openshift_hostname=master01.openshift.yongbok.net openshift_public_hostname=master01.openshift.yongbok.net
master02.openshift.yongbok.net  openshift_ip=192.168.103.124 openshift_public_ip=192.168.103.124 openshift_hostname=master02.openshift.yongbok.net openshift_public_hostname=master02.openshift.yongbok.net
master03.openshift.yongbok.net  openshift_ip=192.168.103.125 openshift_public_ip=192.168.103.125 openshift_hostname=master03.openshift.yongbok.net openshift_public_hostname=master03.openshift.yongbok.net

[etcd]
master01.openshift.yongbok.net  openshift_ip=192.168.103.123 openshift_public_ip=192.168.103.123 openshift_hostname=master01.openshift.yongbok.net openshift_public_hostname=master01.openshift.yongbok.net
master02.openshift.yongbok.net  openshift_ip=192.168.103.124 openshift_public_ip=192.168.103.124 openshift_hostname=master02.openshift.yongbok.net openshift_public_hostname=master02.openshift.yongbok.net
master03.openshift.yongbok.net  openshift_ip=192.168.103.125 openshift_public_ip=192.168.103.125 openshift_hostname=master03.openshift.yongbok.net openshift_public_hostname=master03.openshift.yongbok.net

[nodes]
master01.openshift.yongbok.net  openshift_ip=192.168.103.123 openshift_public_ip=192.168.103.123 openshift_hostname=master01.openshift.yongbok.net openshift_public_hostname=master01.openshift.yongbok.net openshift_schedulable=False
master02.openshift.yongbok.net  openshift_ip=192.168.103.124 openshift_public_ip=192.168.103.124 openshift_hostname=master02.openshift.yongbok.net openshift_public_hostname=master02.openshift.yongbok.net openshift_schedulable=False
master03.openshift.yongbok.net  openshift_ip=192.168.103.125 openshift_public_ip=192.168.103.125 openshift_hostname=master03.openshift.yongbok.net openshift_public_hostname=master03.openshift.yongbok.net openshift_schedulable=False
router.openshift.yongbok.net  openshift_ip=192.168.103.126 openshift_public_ip=192.168.103.126 openshift_hostname=router.openshift.yongbok.net openshift_public_hostname=router.openshift.yongbok.net
minion01.openshift.yongbok.net  openshift_ip=192.168.103.127 openshift_public_ip=192.168.103.127 openshift_hostname=minion01.openshift.yongbok.net openshift_public_hostname=minion01.openshift.yongbok.net
minion02.openshift.yongbok.net  openshift_ip=192.168.103.128 openshift_public_ip=192.168.103.128 openshift_hostname=minion02.openshift.yongbok.net openshift_public_hostname=minion02.openshift.yongbok.net
minion03.openshift.yongbok.net  openshift_ip=192.168.103.129 openshift_public_ip=192.168.103.129 openshift_hostname=minion03.openshift.yongbok.net openshift_public_hostname=minion03.openshift.yongbok.net

# 해당 노드에 대한 region 설정 부분 입니다.
# App에 대한 응답 및 요청을 Router가 처리 할 수 있도록 기본값으로 설정 하고.
# Minion들은 Amazon의 AZ(Availability Zone) 처럼 설정 하는 부분도 있습니다.
# region별로 서버가 나눠져 있을 경우 이 작업을 통해 나눌 수 있습니다.
router.openshift.yongbok.net openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
minion01.openshift.yongbok.net openshift_node_labels="{'region': 'primary', 'zone': 'asia-seoul-1a'}"
minion02.openshift.yongbok.net openshift_node_labels="{'region': 'primary', 'zone': 'asia-seoul-1b'}"
minion03.openshift.yongbok.net openshift_node_labels="{'region': 'primary', 'zone': 'asia-seoul-2c'}"

[lb]
openshift.yongbok.net  openshift_ip=192.168.103.122 openshift_public_ip=192.168.103.122 openshift_hostname=openshift.yongbok.net openshift_public_hostname=openshift.yongbok.net

[nfs]
master01.openshift.yongbok.net  openshift_ip=192.168.103.123 openshift_public_ip=192.168.103.123 openshift_hostname=master01.openshift.yongbok.net openshift_public_hostname=master01.openshift.yongbok.net

 

이제 ‘y’ 를 눌러 설치를 진행 합니다.

Wrote atomic-openshift-installer config: /root/.config/openshift/installer.cfg.yml
Wrote ansible inventory: /root/.config/openshift/hosts

Ready to run installation process.

If changes are needed please edit the config file above and re-run.

Are you ready to continue? [y/N]: y

 

설치가 완료 되고 나면 아래와 같은 설치 완료 메세지가 뜨게 됩니다. Enter를 눌러 넘어 갑니다.

PLAY RECAP ******************************************************************** 
localhost                  : ok=21   changed=0    unreachable=0    failed=0   
master01.openshift.yongbok.net : ok=545  changed=24   unreachable=0    failed=0   
master02.openshift.yongbok.net : ok=293  changed=10   unreachable=0    failed=0   
master03.openshift.yongbok.net : ok=293  changed=10   unreachable=0    failed=0   
minion01.openshift.yongbok.net : ok=108  changed=3    unreachable=0    failed=0   
minion02.openshift.yongbok.net : ok=108  changed=3    unreachable=0    failed=0   
minion03.openshift.yongbok.net : ok=108  changed=3    unreachable=0    failed=0   
openshift.yongbok.net      : ok=50   changed=1    unreachable=0    failed=0   
router.openshift.yongbok.net : ok=108  changed=3    unreachable=0    failed=0   


The installation was successful!

If this is your first time installing please take a look at the Administrator
Guide for advanced options related to routing, storage, authentication and much
more:

http://docs.openshift.com/enterprise/latest/admin_guide/overview.html

Press any key to continue ...

 

OpenShift Origin (Master Node)


Master 서버에서 web console 서버를 통해 사용자가 프로젝트 및 Application을 실행, 배포 할 수 있습니다.
이를 사용하려면 로그인 계정이 있어야 하므로, htpasswd 를 사용하여 가상 사용자를 만들겠습니다.

[root@deploy ~]# WEB_USER=ruo91
[root@deploy ~]# WEB_PASS=openshift
[root@deploy ~]# for node in {master01,master02,master03}; do
  ssh root@$node "htpasswd -cb /etc/origin/master/openshift-passwd $WEB_USER $WEB_PASS";
done

 

OpenShift Origin (All Node)


모든 설치를 반영하기 위해서 모든 노드를 재시작 합니다.

[root@deploy ~]# for node in {openshift,master01,master02,master03,router,minion01,minion02,minion03}; do
  ssh root@$node "reboot";
done

 

OpenShift Origin (Master Node)


재부팅이 완료 되고 나면 Master 서버중 하나에 SSH 로 접속하여,
oc 명령어를 통해 router 서버가 default로 등록 될 수 있도록 수정 합니다.

[root@master01 ~]# oc edit namespace default
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    openshift.io/node-selector:	region=infra
    openshift.io/sa.initialized-roles: "true"
    openshift.io/sa.scc.mcs: s0:c3,c2
    openshift.io/sa.scc.supplemental-groups: 1000010000/10000
    openshift.io/sa.scc.uid-range: 1000010000/10000
  creationTimestamp: 2016-06-28T04:32:28Z
  name: default
  resourceVersion: "277"
  selfLink: /api/v1/namespaces/default
  uid: 525914b5-3ce9-11e6-bd61-525400ef3247
spec:
  finalizers:
  - kubernetes
  - openshift.io/origin
status:
  phase: Active

 

정상적으로 반영이 되어있는지 출력 결과를 통해 살펴 보도록 합니다.

[root@master01 ~]# oc get namespace default -o yaml
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    openshift.io/node-selector: region=infra
    openshift.io/sa.initialized-roles: "true"
    openshift.io/sa.scc.mcs: s0:c3,c2
    openshift.io/sa.scc.supplemental-groups: 1000010000/10000
    openshift.io/sa.scc.uid-range: 1000010000/10000
  creationTimestamp: 2016-06-28T04:32:28Z
  name: default
  resourceVersion: "1918"
  selfLink: /api/v1/namespaces/default
  uid: 525914b5-3ce9-11e6-bd61-525400ef3247
spec:
  finalizers:
  - kubernetes
  - openshift.io/origin
status:
  phase: Active

 

OpenShift Origin Web Console


기본적으로 Web Console은 8443 포트를 통해 접속을 합니다.
접속시 주소는 HA 구성시 지정 하였던 ‘openshift.yongbok.net’ 을 통해 접속 하시면 됩니다.

https://openshift.yongbok.net:8443/

 

– 로그인 화면
web console용 로그인 계정을 사용하여 로그인 합니다. 
openshift_origin_1

 

2. 프로젝트 화면
로그인과 동시에 프로젝트를 만들 수 있는 화면이 반겨 줍니다. ‘New Project’ 를 눌러 생성 해보겠습니다.
openshift_origin_2

 

Name: 사용할 서브 도메인을 말합니다.
Display Name: Web Console에서 보여질 프로젝트 이름 입니다.
Description: 프로젝트의 보조 설명 부분 입니다.
openshift_origin_3

 

3. Application 빌드
예제로 NodeJS를 검색하여 ‘nodejs:latest’를 빌드 해보겠습니다.
openshift_origin_4

 

Name: 서브 도메인으로 사용할 이름 입니다.
Git Repository URL: Dockerfile 이 존재하는 GitHUB 저장소를 뜻합니다.
‘Create’ 버튼을 눌러 빌드를 시작 합니다.
openshift_origin_5

 

상단 ‘Continue to overview’를 눌러 나옵니다.
openshift_origin_6

 

빌드가 진행 되는 중이며, 좀더 자세한 상황을 보도록 하겠습니다.
openshift_origin_7
openshift_origin_8

openshift_origin_9

 

4. Applicaction 배포
가운데 보이는 화샅표를 통해 Pods를 Scale-Up/Down 합니다.

openshift_origin_10

 

생성 된 Pods의 토폴로지도 볼수 있고
openshift_origin_11

 

Pods 정보도 볼수 있습니다.
openshift_origin_12

 

왼편에 “Overview”를 눌러 생성 된 Application의 서브 도메인을 클릭 하면 실제로 접속이 되는 것을 확인 할 수 있습니다.
openshift_origin_13
감사합니다. 🙂

 

Reference


https://github.com/openshift/origin
https://docs.openshift.org/latest/install_config/install/advanced_install.html