Вы ищете простой способ настройки локального кластера OpenShift 4 на своем ноутбуке?
Контейнеры Red Hat CodeReady позволяют запускать минимальный кластер OpenShift 4.2 или более поздней версии на локальном ноутбуке или настольном компьютере.
Его следует использовать только для целей разработки и тестирования.
Мы предоставим отдельное руководство для настройки производственного кластера OpenShift 4.
Red Hat CodeReady Containers – это обычная установка OpenShift со следующими заметными отличиями:
- Он использует один узел, который ведет себя как мастер и как рабочий узел.
- Операторы
machine-config
иmonitoring
по умолчанию отключены.
- Эти отключенные операторы приведут к неработоспособности соответствующие части веб-консоли.
- По той же причине в настоящее время нет пути обновления до более новых версий OpenShift.
- Из-за технических ограничений кластер CodeReady Containers является эфемерным, и его необходимо будет заново создавать с нуля раз в месяц, используя более новую версию.
- Экземпляр OpenShift работает на виртуальной машине, что может вызвать некоторые другие различия, в частности, связанные с внешней сетью.
Минимальные системные требования
Для CodeReady Containers требуются следующие минимальные требования к оборудованию и операционной системе.
- 4 виртуальных процессора (vCPU)
- 8 ГБ памяти
- 35 ГБ дискового пространства
Контейнеры CodeReady можно запускать на Windows, macOS, но эта установка была протестирована на CentOS 7/8 и Fedora 31.
Контейнеры CodeReady поставляются в виде виртуальной машины Red Hat Enterprise Linux, которая поддерживает собственные гипервизоры для Linux, macOS и Microsoft Windows 10.
Шаг 1. Установите необходимые программные пакеты
CodeReady Containers требует, чтобы пакеты libvirt и NetworkManager были установлены в хост-системе.
------- Fedora ----------
$ sudo dnf install NetworkManager qemu-kvm libvirt virt-install
$ sudp systemctl enable --now libvirtd
------ CentOS 7 ---------
$ sudo yum -y install qemu-kvm libvirt virt-install bridge-utils NetworkManager
$ sudo systemctl enable --now libvirtd
Шаг 2: Установите контейнеры CodeReady
Загрузите последний двоичный файл для CRC из приведенной ниже настройки URL.its.
wget https://mirror.openshift.com/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz
tar xvf crc-linux-amd64.tar.xz
cd crc*/
sudo cp crc /usr/local/bin
$ crc version
crc version: 1.2.0+c2e3c0f
OpenShift version: 4.2.8 (embedded in binary)
$ crc --help
CodeReady Containers is a tool that manages a local OpenShift 4.x cluster optimized for testing and development purposes
Usage:
crc [flags]
crc [command]
Available Commands:
config Modify crc configuration
console Open the OpenShift Web Console in the default browser
delete Delete the OpenShift cluster
help Help about any command
ip Get IP address of the running OpenShift cluster
oc-env Add the 'oc' binary to PATH
setup Set up prerequisites for the OpenShift cluster
start Start the OpenShift cluster
status Display status of the OpenShift cluster
stop Stop the OpenShift cluster
version Print version information
Flags:
-f, --force Forcefully perform an action
-h, --help help for crc
--log-level string log level (e.g. "debug | info | warn | error") (default "info")
Шаг 3. Развертывание виртуальной машины CodeReady Containers.
Запустите команду crc setup
, чтобы настроить операционную систему хоста для виртуальной машины CodeReady Containers.
$ crc setup
INFO Checking if running as non-root
INFO Caching oc binary
INFO Setting up virtualization
INFO Setting up KVM
INFO Installing libvirt service and dependencies
INFO Adding user to libvirt group
INFO Enabling libvirt
INFO Starting libvirt service
INFO Will use root access: start libvirtd service
INFO Checking if a supported libvirt version is installed
INFO Installing crc-driver-libvirt
INFO Removing older system-wide crc-driver-libvirt
INFO Setting up libvirt 'crc' network
INFO Starting libvirt 'crc' network
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Writing Network Manager config for crc
INFO Will use root access: write NetworkManager config in /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf
INFO Will use root access: execute systemctl daemon-reload command
INFO Will use root access: execute systemctl stop/start command
INFO Writing dnsmasq config for crc
INFO Will use root access: write dnsmasq configuration in /etc/NetworkManager/dnsmasq.d/crc.conf
INFO Will use root access: execute systemctl daemon-reload command
INFO Will use root access: execute systemctl stop/start command
INFO Unpacking bundle from the CRC binary
$ crc start
INFO Checking if running as non-root
INFO Checking if oc binary is cached
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 libvirt is enabled
INFO Checking if libvirt daemon is running
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking if libvirt 'crc' network is available
INFO Checking if libvirt 'crc' network is active
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
? Image pull secret [? for help] *
INFO Extracting bundle: crc_libvirt_4.2.8.crcbundle ...
INFO Creating CodeReady Containers VM for OpenShift 4.2.8...
INFO Verifying validity of the cluster certificates ...
INFO Check internal and public DNS query ...
INFO Copying kubeconfig file to instance dir ...
INFO Adding user's pull secret and cluster ID ...
INFO Starting OpenShift cluster ... [waiting 3m]
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443'
INFO To login as an admin, username is 'kubeadmin' and password is UMeRe-hBQAi-JJ4Bi-8ynRD
INFO
INFO You can now run 'crc console' and use these credentials to access the OpenShift web console
Started the OpenShift cluster
WARN The cluster might report a degraded or error state. This is expected since several operators have been disabled to lower the resource usage. For more information, please consult the documentation
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443' INFO To login as an admin, username is 'kubeadmin' and password is UMeRe-hBQAi-JJ4Bi-8ynRD INFO You can now run 'crc console' and use these credentials to access the OpenShift web console
$ crc oc-env export PATH="/home/jmutai/.crc/bin:$PATH" eval $(crc oc-env)
$ source ~/.bashrc
-- или --
$ source ~/.zshrc
$ oc cluster-info
Kubernetes master is running at https://api.crc.testing:6443
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
$ oc get nodes
NAME STATUS ROLES AGE VERSION
crc-2n9vw-master-0 Ready master,worker 5d13h v1.14.6+6ac6aa4b0
$ oc config view
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://api.crc.testing:6443
name: api-crc-testing:6443
- cluster:
certificate-authority: /home/jmutai/.minikube/ca.crt
server: https://192.168.39.35:8443
name: minikube
contexts:
- context:
cluster: api-crc-testing:6443
user: developer/api-crc-testing:6443
name: /api-crc-testing:6443/developer
- context:
cluster: api-crc-testing:6443
namespace: default
user: kube:admin/api-crc-testing:6443
name: default/api-crc-testing:6443/kube:admin
- context:
cluster: minikube
user: minikube
name: minikube
current-context: default/api-crc-testing:6443/kube:admin
kind: Config
preferences: {}
users:
- name: developer/api-crc-testing:6443
user:
token: Pvqjq-b5HkV9UQtOYH8P9yOtm17MrOUVs-eaiSeQqXA
- name: kube:admin/api-crc-testing:6443
user:
token: LDrdGJMUpPUAxtg0IvWynedbtSBLjs8S2S6kdpvbMU8
- name: minikube
user:
client-certificate: /home/jmutai/.minikube/client.crt
client-key: /home/jmutai/.minikube/client.key
$ oc get co
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE
authentication 4.2.8 True False False 5d13h
cloud-credential 4.2.8 True False False 5d13h
cluster-autoscaler 4.2.8 True False False 5d13h
console 4.2.8 True False False 5d13h
dns 4.2.8 True False False 17m
image-registry 4.2.8 True False False 5d13h
ingress 4.2.8 True False False 5d13h
insights 4.2.8 True False False 5d13h
kube-apiserver 4.2.8 True False False 5d13h
kube-controller-manager 4.2.8 True False False 5d13h
kube-scheduler 4.2.8 True False False 5d13h
machine-api 4.2.8 True False False 5d13h
machine-config 4.2.8 True False False 5d13h
marketplace 4.2.8 True False False 17m
monitoring 4.2.8 False True True 5d13h
network 4.2.8 True False False 5d13h
node-tuning 4.2.8 True False False 17m
openshift-apiserver 4.2.8 True False False 9h
openshift-controller-manager 4.2.8 True False False 9h
openshift-samples 4.2.8 True False False 5d13h
operator-lifecycle-manager 4.2.8 True False False 5d13h
operator-lifecycle-manager-catalog 4.2.8 True False False 5d13h
operator-lifecycle-manager-packageserver 4.2.8 True False False 17m
service-ca 4.2.8 True False False 5d13h
service-catalog-apiserver 4.2.8 True False False 5d13h
service-catalog-controller-manager 4.2.8 True False False 5d13h
storage 4.2.8 True False False 5d13h
Шаг 4: Доступ к кластеру OpenShift
Вы можете получить доступ к кластеру OpenShift, развернутому локально из CLI или открыв консоль OpenShift 4.x в своем веб-браузере.
$ oc login -u developer -p developer https://api.crc.testing:6443
The server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y
Login successful.
You don't have any projects. You can try to create a new project, by running
oc new-project <projectname>
$ oc login -u kubeadmin -p UMeRe-hBQAi-JJ4Bi-8ynRD https://api.crc.testing:6443
Login successful.
You have access to 51 projects, the list has been suppressed. You can list all projects with 'oc projects'
Using project "default".
$ crc console
Войдите с учетными данными, напечатанными ранее.
Шаг 5: остановка кластера OpenShift
Чтобы остановить ваш кластер OpenShift, выполните команду:
$ crc stop
Stopping the OpenShift cluster, this may take a few minutes...
Stopped the OpenShift cluster
crc start
INFO Checking if running as non-root
INFO Checking if oc binary is cached
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 libvirt is enabled
INFO Checking if libvirt daemon is running
INFO Checking if a supported libvirt version is installed
INFO Checking if crc-driver-libvirt is installed
INFO Checking if libvirt 'crc' network is available
INFO Checking if libvirt 'crc' network is active
INFO Checking if NetworkManager is installed
INFO Checking if NetworkManager service is running
INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists
INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists
INFO Starting CodeReady Containers VM for OpenShift 4.2.8...
INFO Verifying validity of the cluster certificates ...
INFO Check internal and public DNS query ...
INFO Starting OpenShift cluster ... [waiting 3m]
INFO
INFO To access the cluster, first set up your environment by following 'crc oc-env' instructions
INFO Then you can access it by running 'oc login -u developer -p developer https://api.crc.testing:6443'
INFO To login as an admin, username is 'kubeadmin' and password is UMeRe-hBQAi-JJ4Bi-8ynRD
INFO
...
Удаление виртуальной машины CodeReady Containers
Если вы хотите удалить существующую виртуальную машину CodeReady Containers, запустите:
$ crc delete