Okuma süresi: 7 dakika | 24 Ağustos 2022 | Yazar: Emre Yardımcı 

Red Hat OpenShift Local

Eskiden Red Hat CodeReady Containers olarak bilinen şuan ise Red Hat’in OpenShift Local olarak isimlendirdiği, yazılımcılar için kolay kurulabilir ve erişilebilir bir OpenShift ortamı sağlayan nokta atışı bir çözüm. Tek node ile ayağa kalkan OpenShift Local, yazılımcıların cloud native geliştirme süreçlerini ve testlerini hızlandırmak için tasarlanmıştır.

 

Bu yazımızda ise OpenShift Local uygulamasını direk kendi çalışma alanlarına kurmak istemeyen kullanıcılar için sanallaştırma üzerine kurulumu anlatacağız. Ben sanallaştırma olarak hem Oracle VirtualBox hem de Microsoft HyperV kullanarak test ettim.

 

Öncelikle sunucularımız hazırlamamız gerekmektedir. Sunucu hazırlığı için sıklıkla kullandığım Vagrant uygulamasını kullanacağım. Dileyenler kendi sunucularını manuel olarak iso dosyaları üzerinden hazırlayabilirler.

 

Kullandığım Vagrantfile tanımları şu şekildedir;

HYPERV:

# -*- mode: ruby -*-

# vi: set ft=ruby :

 

prvider=“hyperv”

IMAGE_NAME = “generic/centos8”

 

Vagrant.configure(“2”) do |config|

 

    config.vm.define “bastion” do |bastion|

        bastion.vm.box = IMAGE_NAME

        bastion.vm.hostname = ‘hyperv-local.quasys.com’

    bastion.vm.provider #{prvider} do |vb|

      vb.vmname = “openshift-local”

      vb.maxmemory = 12192

      vb.memory = 10192

      vb.cpus = 4

    end

  end

end

 

VIRTUALBOX:

# -*- mode: ruby -*-

# vi: set ft=ruby :

 

prvider=“virtualbox”

IMAGE_NAME = “generic/centos8”

 

Vagrant.configure(“2”) do |config|

 

    config.vm.define “bastion” do |bastion|

        bastion.vm.box = IMAGE_NAME

        bastion.vm.hostname = ‘virtualbox-local.quasys.com’

    bastion.vm.provider #{prvider} do |vb|

      vb.name = “openshift-local”

      vb.memory = 12192

      vb.cpus = 4

    end

  end

end

Burada dikkat edilmesi gereken memory tanımlarıdır.

OpenShift Cluster minimum olarak aşağıdaki kaynakları beklemektedir. Bu kaynakaların sağlanamaması durumunda kurulum hata almaktadır.

  • 4 CPU
  • 9 GB memory
  • 35 GB storage

Daha sonra aşağıdaki komut ile birlikte sunucularımı hazırlıyoruz.

vagrant up

Kurulum adımları;

Öncelikle bu link üzerinden Red Hat hesabınız ile birlikte veya aşağıdaki adresten wget yardımı ile birlikte linux için “crc” indiriyoruz. Link üzerinden indirirme işlemi öncesi Linux işletim sistemi seçilmesi gerekmektedir. Daha sonra ise “Pull Secret” dosyanızı indirmeyi unutmayınız. Kurulum sırasında bu secret, crc cli tarafından talep edilecektir.

 

İndirilen dosyayı tar’dan çıkartıp kullanabilir ya da ilgili folder altına taşıyabiliriz.

wget https://developers.redhat.com/contentgateway/rest/mirror/pub/openshiftv4/clients/crc/latest/crclinuxamd64.tar.xz

tarxf crclinuxamd64.tar.xz

cpr crclinux2.6.0amd64/crc /usr/bin/

Kurulumu başlatmadan önce nested vitualization aktif edilmiş olması gerekmektedir. Bunun için aşağıdaki komutları çalıştırmalısınız;

HYPERV:

Set-VMProcessor -VMName openshift-local -ExposeVirtualizationExtensions $true

VIRTUALBOX:

VBoxManage modifyvm openshift-local –nested-hw-virt on

Daha sonra crc komutunu non-root bir kullanıcı kullanarak “crc setup” ile çalıştırıyoruz. Yaklaşık 3.5GB dolayında bir indirme işlemi yapacaktır.

[vagrant@node1 ~]$ crc setup

INFO Using bundle path /home/vagrant/.crc/cache/crc_libvirt_4.11.0_amd64.crcbundle

INFO Checking if running as nonroot              

INFO Checking if running inside WSL2              

INFO Checking if crcadminhelper executable is cached

INFO Checking for obsolete adminhelper executable

INFO Checking if running on a supported CPU architecture

INFO Checking minimum RAM requirements            

INFO Checking if crc executable symlink exists    

INFO Checking if Virtualization is enabled        

INFO Checking if KVM is enabled                  

INFO Checking if libvirt is installed            

INFO Installing libvirt service and dependencies  

INFO Using root access: Installing virtualization packages

INFO Checking if user is part of libvirt group    

INFO Adding user to libvirt group                

INFO Using root access: Adding user to the libvirt group

INFO Checking if active user/process is currently part of the libvirt group

INFO Checking if libvirt daemon is running        

WARN No active (running) libvirtd systemd unit could be foundmake sure one of libvirt systemd units is enabled so that its autostarted at boot time.

INFO Starting libvirt service                    

INFO Using root access: Executing systemctl daemonreload command

INFO Using root access: Executing systemctl start libvirtd

INFO Checking if a supported libvirt version is installed

INFO Checking if crcdriverlibvirt is installed  

INFO Installing crcdriverlibvirt                

INFO Checking crc daemon systemd service          

INFO Setting up crc daemon systemd service        

INFO Checking crc daemon systemd socket units    

INFO Setting up crc daemon systemd socket units  

INFO Checking if systemdnetworkd is running      

INFO Checking if NetworkManager is installed      

INFO Checking if NetworkManager service is running

INFO Checking if /etc/NetworkManager/conf.d/crcnmdnsmasq.conf exists

INFO Writing Network Manager config for crc      

INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/conf.d/crcnmdnsmasq.conf

INFO Using root access: Changing permissions for /etc/NetworkManager/conf.d/crcnmdnsmasq.conf to 644  

INFO Using root access: Executing systemctl daemonreload command

INFO Using root access: Executing systemctl reload NetworkManager

INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists

INFO Writing dnsmasq config for crc              

INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/dnsmasq.d/crc.conf

INFO Using root access: Changing permissions for /etc/NetworkManager/dnsmasq.d/crc.conf to 644  

INFO Using root access: Executing systemctl daemonreload command

INFO Using root access: Executing systemctl reload NetworkManager

INFO Checking if libvirt ‘crc’ network is available

INFO Setting up libvirt ‘crc’ network            

INFO Checking if libvirt ‘crc’ network is active  

INFO Starting libvirt ‘crc’ network              

INFO Checking if CRC bundle is extracted in ‘$HOME/.crc’

INFO Checking if /home/vagrant/.crc/cache/crc_libvirt_4.11.0_amd64.crcbundle exists

INFO Getting bundle for the CRC executable        

INFO Downloading crc_libvirt_4.11.0_amd64.crcbundle

3.28 GiB / 3.28 GiB [————————————————————————————————————————–] 100.00% 7.58 MiB p/s

INFO Uncompressing /home/vagrant/.crc/cache/crc_libvirt_4.11.0_amd64.crcbundle

crc.qcow2: 12.48 GiB / 12.48 GiB [————————————————————————————————————————–] 100.00%

oc: 118.13 MiB / 118.13 MiB [——————————————————————————————————————————-] 100.00%

Your system is correctly setup for using CRC. Use ‘crc start’ to start the instance

 

Kurulum başarılı tamamlandığında “crc start” komutu ile cluster’ımızı başlatıyor ve daha önce indirdiğimiz pull secret bilgisini sağlıyoruz.

[vagrant@node1 ~]$ crc start

INFO Checking if running as nonroot              

INFO Checking if running inside WSL2              

INFO Checking if crcadminhelper executable is cached

INFO Checking for obsolete adminhelper executable

INFO Checking if running on a supported CPU architecture

INFO Checking minimum RAM requirements            

INFO Checking if crc executable symlink exists    

INFO Checking if Virtualization is enabled        

INFO Checking if KVM is enabled                  

INFO Checking if libvirt is installed            

INFO Checking if user is part of libvirt group    

INFO Checking if active user/process is currently part of the libvirt group

INFO Checking if libvirt daemon is running        

INFO Checking if a supported libvirt version is installed

INFO Checking if crcdriverlibvirt is installed  

INFO Checking crc daemon systemd socket units    

INFO Checking if systemdnetworkd is running      

INFO Checking if NetworkManager is installed      

INFO Checking if NetworkManager service is running

INFO Checking if /etc/NetworkManager/conf.d/crcnmdnsmasq.conf exists

INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists

INFO Checking if libvirt ‘crc’ network is available

INFO Checking if libvirt ‘crc’ network is active  

INFO Loading bundle: crc_libvirt_4.11.0_amd64…  

CRC requires a pull secret to download content from Red Hat.

You can copy it from the Pull Secret section of https://console.redhat.com/openshift/create/local.

? Please enter the pull secret **************************************************************************************************************************************

WARN Cannot add pull secret to keyring: The name org.freedesktop.secrets was not provided by any .service files

INFO Creating CRC VM for openshift 4.11.0…      

INFO Generating new SSH key pair…              

INFO Generating new password for the kubeadmin user

INFO Starting CRC VM for openshift 4.11.0…      

INFO CRC instance is running with IP 192.168.130.11

INFO CRC VM is running                            

INFO Updating authorized keys…                  

INFO Check internal and public DNS query…      

INFO Check DNS query from host…                

INFO Verifying validity of the kubelet certificates

INFO Starting kubelet service                    

INFO Waiting for kubeapiserver availability… [takes around 2min]

INFO Adding user‘s pull secret to the cluster…  

INFO Updating SSH key to machine config resource…

INFO Waiting for user’s pull secret part of instance disk

INFO Changing the password for the kubeadmin user

INFO Updating cluster ID…                      

INFO Updating root CA cert to adminkubeconfigclientca configmap

INFO Starting openshift instance… [waiting for the cluster to stabilize]

INFO 3 operators are progressing: imageregistry, network, openshiftcontrollermanager

INFO Operator openshiftcontrollermanager is progressing

INFO Operator authentication is progressing      

ERRO Cluster is not ready: cluster operators are still not stable after 10m0.883392953s

INFO Adding crcadmin and crcdeveloper contexts to kubeconfig

Started the OpenShift cluster.

 

The server is accessible via web console at:

  https://consoleopenshiftconsole.appscrc.testing

 

Log in as administrator:

  Username: kubeadmin

  Password: TNCF53TLJSu2x87vZuUe

 

Log in as user:

  Username: developer

  Password: developer

 

Use the ‘oc’ command line interface:

  $ eval $(crc ocenv)

  $ oc loginu developer https://api.crc.testing:6443

Daha sonra dışarıdan erişmek için haproxy kurarak proxy sağlayacağız. Dileyenler Apache httpd gibi alternatif yöntemleri kullanabilirler. Komut adımları şöyledir;

#HAProxy kurulumu

sudo dnfy install haproxy policycoreutilspythonutils

 

#Firewall izinlerinin tanımlanması

sudo systemctl start firewalld

sudo firewallcmdaddport=80/tcppermanent

sudo firewallcmdaddport=6443/tcppermanent

sudo firewallcmdaddport=443/tcppermanent

sudo systemctl restart firewalld

sudo semanage portat http_port_tp tcp 6443

 

#HAProxy configurasyon dosyasının hazırlanması

export SERVER_IP=$(hostnameipaddress)

export CRC_IP=$(crc ip)

cd /etc/haproxy

sudo cp haproxy.cfg haproxy.cfg.orig

 

#haproxy.cfg dosyası

##################################################

defaults

    mode http

    log global

    option httplog

    option  httpserverclose

    option  dontlognull

    option  redispatch

    option  contstats

    retries 3

    backlog 10000

    timeout client          25s

    timeout connect          5s

    timeout server          25s

    timeout tunnel        3600s

    timeout httpkeepalive  1s

    timeout httprequest    15s

    timeout queue           30s

    timeout tarpit          60s

    defaultserver inter 3s rise 2 fall 3

    option forwardfor

 

frontend apps

    bind SERVER_IP:80

    bind SERVER_IP:443

    option tcplog

    mode tcp

    default_backend apps

 

backend apps

    mode tcp

    balance roundrobin

    option tcpcheck

    server webserver1 CRC_IP check port 80

 

frontend api

    bind SERVER_IP:6443

    option tcplog

    mode tcp

    default_backend api

 

backend api

    mode tcp

    balance roundrobin

    option tcpcheck

    server webserver1 CRC_IP:6443 check port 6443

##################################################

 

#Config dosyasındaki değişkenlerin ayarlanması

sudo sedi “s/SERVER_IP/$SERVER_IP/g” haproxy.cfg

sudo sedi “s/CRC_IP/$CRC_IP/g” haproxy.cfg

 

#HAProxy servisinin çalıştırılması

sudo systemctl start haproxy

Client tarafından erişim için host dosyanıza sanal sunucunuzun IP bilgisini girmeniz gerekmektedir. DNS tanımlarını sanal sunucunuzdaki “/etc/hosts” aşağıdaki tanımı alarak client makinenizin host dosyası içerisine koyabilirsiniz. Tanımdaki 192.168.130.11 IP bilgisini sanak makinenizin IP’si ile değiştiriniz.

192.168.130.11 api.crc.testing canary-openshift-ingress-canary.apps-crc.testing console-openshift-console.apps-crc.testing default-route-openshift-image-registry.apps-crc.testing downloads-openshift-console.apps-crc.testing oauth-openshift.apps-crc.testing

 

Diğer yardımcı crc komutlarını aşağıda bulabilirsiniz;

crc start –log-level debug | sanal makineyi başlatırken hata almanız durumunda debug mod ile hata incelemesi yapabilirsiniz.

crc stop | sanal makineyi durdurmanızı sağlar.

crc delete | sanal makinenin silinmesini sağlar.

crc cleanup | tüm crc ayarlarını temizler.

crc config | get, set, unset veya view gibi alt komutlar ile crc konfigürasyonlarını yönetmenizi sağlar.

crc config view | tüm crc konfigürasyonlarını listelemenizi sağlar.

crc status | sanal makinenizin durumunu gösterir.

crc version | cli, Podman ve OCP versiyon bilgilerini görebilirsiniz.

crc console | OCP web konsolunu varsayılan tarayıcı üzerinde açar.

crc console –credentials | OCP cluster admin ve developer kullanıcı bilgilerini sağlar.

Kaynaklar


0 yorum

Bir cevap yazın

Avatar placeholder

E-posta hesabınız yayımlanmayacak.