okd3.11

Updated: 7/29/2020

更新时间:2020年7月29日

Who wants to run an OKD 4 SNC on their Windows 10 workstation? Me for one.

谁想要在Windows 10工作站上运行OKD 4 SNC? 我一个。

This is guide is geared towards people who want to try ODK 4 on an existing workstation (minimum 24GB of RAM) without purchasing additional hardware like a NUC or home lab server.

本指南适用于希望在现有工作站上尝试ODK 4(最小24GB RAM)而无需购买其他硬件(如NUC或家庭实验室服务器)的人们。

OpenShift (OCP) has CodeReady Containers where you can set up an OpenShift cluster on your local machine for development and testing purposes. Currently, the OKD version of CodeReady Containers is still in development. This guide will walk you through installing an OKD 4.5 Single Node Cluster on your Windows 10 (Pro, Enterprise, or Education) workstation using Hyper-V.

OpenShift(OCP)具有CodeReady容器 ,您可以在其中在本地计算机上设置OpenShift集群以进行开发和测试。 当前,OKRead版本的CodeReady容器仍在开发中。 本指南将指导您使用Hyper-V在Windows 10(Pro,Enterprise或Education)工作站上安装OKD 4.5单节点群集。

(VM Overview:)

For this installation, I used a Windows 10 Pro laptop with 32GB RAM. Here is a breakdown of the virtual machines and network layout:

对于此安装,我使用了具有32GB RAM的Windows 10 Pro笔记本电脑。 这是虚拟机和网络布局的细分:

nuc9如何进bios nuc进入bios方法_python

(Enable Hyper-V using PowerShell)

Open a PowerShell console as Administrator and run the following command:

以管理员身份打开PowerShell控制台并运行以下命令:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

nuc9如何进bios nuc进入bios方法_java_02

If the command couldn’t be found, make sure you’re running PowerShell as Administrator.

如果找不到该命令,请确保您以管理员身份运行PowerShell。

When the installation has completed, reboot.

安装完成后,请重新启动。

(Create a NAT switch in Hyper-V using Powershell)

Open a PowerShell console as Administrator and run the following commands to create a Virtual Switch:

以管理员身份打开PowerShell控制台,然后运行以下命令来创建虚拟交换机:

$Natswitchname = “OKD4-NATSwitch”
$NATNetwork = “192.168.200.0”
$NATrouteraddress = “192.168.200.1”
$NATPrefixLength = “24”New-VMSwitch –SwitchName $Natswitchname –SwitchType Internal –Verbose
$natswitch = Get-NetAdapter | where {(($_.name -like (“vEthernet ($Natswitchname)”)))}
New-NetIPAddress $NATrouteraddress -PrefixLength $NATPrefixLength -InterfaceIndex $natswitch.interfaceindex -Verbose
$NATNetworkFull = $NATNetwork + “/” + $NATPrefixLength
New-NetNat -Name HyperV-NatNetwork -InternalIPInterfaceAddressPrefix $NATNetworkFull -Verbose

nuc9如何进bios nuc进入bios方法_java_03

Open the Hyper-V Manager, then Virtual Switch Manager, and verify the OKD4-NATSwitch has been created.

打开Hyper-V管理器,然后打开虚拟交换机管理器,并确认已创建OKD4-NATSwitch。

nuc9如何进bios nuc进入bios方法_leetcode_04

(Create the okd4-services VM:)

The okd-4services VM is used to host DNS, haproxy, DHCP, and web services.

okd-4services VM用于托管DNS,haproxy,DHCP和Web服务。

Download the Fedora Server Standard ISO.

下载 Fedora服务器标准ISO。

nuc9如何进bios nuc进入bios方法_java_05

Open the Hyper-V Manager and create a new Virtual Machine.

打开Hyper-V管理器并创建一个新的虚拟机。

nuc9如何进bios nuc进入bios方法_windows_06

Choose a name for the VM and select the location.

选择虚拟机的名称,然后选择位置。

nuc9如何进bios nuc进入bios方法_python_07

Choose Generation 2.

选择第二代。

nuc9如何进bios nuc进入bios方法_leetcode_08

Set the Startup Memory to 1024 MB.

将启动内存设置为1024 MB。

nuc9如何进bios nuc进入bios方法_leetcode_09

Select the OKD4-NATSwitch connection.

选择OKD4-NATSwitch连接。

nuc9如何进bios nuc进入bios方法_leetcode_10

Create a virtual hard disk. I used the defaults.

创建一个虚拟硬盘。 我使用默认值。

nuc9如何进bios nuc进入bios方法_java_11

Select to “Install … from a bootable image file” and Browse to your Fedora Server ISO. Then click finish.

选择“从可引导映像文件安装…”,然后浏览至Fedora Server ISO。 然后单击完成。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_12

Edit the VM settings and change the boot order to HD, DVD, Network.

编辑VM设置,然后将启动顺序更改为HD,DVD,网络。

nuc9如何进bios nuc进入bios方法_leetcode_13

Disable Secure Boot.

禁用安全启动。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_14

Change your Virtual Processors to “2”.

将您的虚拟处理器更改为“ 2”。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_15

Change your Dynamic Memory to Min 512MB and Max 1024MB. Then start the VM.

将您的动态内存更改为最小512MB和最大1024MB。 然后启动虚拟机。

nuc9如何进bios nuc进入bios方法_java_16

(Install Fedora Server 32 on the okd4-services VM:)

Run through the installation and choose your Installation Destination.

运行安装并选择安装目标。

nuc9如何进bios nuc进入bios方法_python_17

For Software Selection, choose “Fedora Custom Operating System” and include the “Guest Agents” add-on.

对于软件选择,选择“ Fedora自定义操作系统”,并包括“ Guest Agents”附加组件。

nuc9如何进bios nuc进入bios方法_java_18

Enable the NIC connected to the VM Network and set the hostname as okd4-services, then click Apply. Click configure, IPv4 Settings, change the Method to “Manual” and set the IP settings as shown, then click save.

启用连接到VM网络的NIC,并将主机名设置为okd4-services,然后单击Apply。 单击“配置”,“ IPv4设置”,将“方法”更改为“手动”,然后如图所示设置IP设置,然后单击“保存”。

nuc9如何进bios nuc进入bios方法_python_19

Set the Root password, and create an admin user and set the password. Click “Begin Installation” to start the install.

设置“ root”密码,并创建一个admin用户并设置密码。 单击“开始安装”开始安装。

nuc9如何进bios nuc进入bios方法_windows_20

After the installation has completed open a command prompt and SSH to the okd4-services VM.

安装完成后,打开命令提示符并SSH到okd4-services VM。

ssh 192.168.200.10

nuc9如何进bios nuc进入bios方法_leetcode_21

Install the additional packages, update the OS, and reboot.

安装其他软件包,更新操作系统,然后重新启动。

sudo dnf install -y git wget vim
sudo dnf update -y  && sudo systemctl reboot
(Configure okd4-services VM to host various services:)

The okd4-services VM is used to provide DHCP, DNS, NFS exports, web server, and load balancing.

okd4-services VM用于提供DHCP,DNS,NFS导出,Web服务器和负载平衡。

Open a terminal on the okd4-services VM and clone the okd4-snc-hyperv repo that contains the DHCP, DNS, HAProxy, and install-conf.yaml example files:

在okd4-services VM上打开一个终端,并克隆包含DHCP,DNS,HAProxy和install-conf.yaml示例文件的okd4-snc-hyperv存储库:

cd
git clone https://github.com/cragr/okd4-snc-hyperv.git
cd okd4-snc-hyperv
(Install dhcpd (DHCP))
sudo dnf -y install dhcp-server
sudo cp dhcpd.conf /etc/dhcp/
sudo systemctl enable --now dhcpd
sudo firewall-cmd --add-service=dhcp --permanent
sudo firewall-cmd --reload
(Install bind (DNS))
sudo dnf -y install bind bind-utils

Copy the named config files and zones:

复制命名的配置文件和区域:

sudo cp named.conf /etc/named.conf
sudo cp named.conf.local /etc/named/
sudo mkdir /etc/named/zones
sudo cp db* /etc/named/zones

Enable and start named:

启用并开始命名:

sudo systemctl enable named
sudo systemctl start named
sudo systemctl status named

Create firewall rules:

创建防火墙规则:

sudo firewall-cmd --permanent --add-port=53/udp
sudo firewall-cmd --reload

Change the DNS on the okd4-services VM to 127.0.0.1:

将okd4-services VM上的DNS更改为127.0.0.1:

sudo nmcli connection modify eth0 ipv4.dns "127.0.0.1"

Restart the network services on the okd4-services VM:

在okd4-services VM上重新启动网络服务:

sudo systemctl restart NetworkManager

Test DNS on the okd4-services.

在okd4-服务上测试DNS。

dig okd.local
dig –x 192.168.200.10

With DNS working correctly, you should see the following results:

在DNS正常工作的情况下,您应该看到以下结果:

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_22

nuc9如何进bios nuc进入bios方法_java_23

In an elevated Powershell window set the DNS on the HyperV-NATSwitch to match the okd4-services IP, 192.168.200.10 so you can resolve the DNS entries.

在提升的Powershell窗口中,将HyperV-NATSwitch上的DNS设置为与okd4-services IP 192.168.200.10匹配,以便您解析DNS条目。

Get-NetIpInterface ‘*(OKD4-NATSwitch)’ | Set-DnsClientServerAddress -ServerAddress ‘192.168.200.10’

Ensure you are able to nslookup test.apps.lab.okd.local

确保您能够nslookup test.apps.lab.okd.local

nuc9如何进bios nuc进入bios方法_windows_24

(Install HAProxy:)

In the okd4-services terminal run:

在okd4-services终端中运行:

sudo dnf install haproxy -y

Copy haproxy config from the git okd4_files directory :

从git okd4_files目录复制haproxy配置:

sudo cp haproxy.cfg /etc/haproxy/haproxy.cfg

Start, enable, and verify HA Proxy service:

启动,启用和验证HA代理服务:

sudo setsebool -P haproxy_connect_any 1
sudo systemctl enable haproxy
sudo systemctl start haproxy
sudo systemctl status haproxy

Add OKD firewall ports:

添加OKD防火墙端口:

sudo firewall-cmd --permanent --add-port=6443/tcp
sudo firewall-cmd --permanent --add-port=22623/tcp
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
(Install Apache/HTTPD)
sudo dnf install -y httpd

Change httpd to listen port to 8080:

将httpd更改为将侦听端口设置为8080:

sudo sed -i 's/Listen 80/Listen 8080/' /etc/httpd/conf/httpd.conf

Enable and Start httpd service/Allow port 8080 on the firewall:

在防火墙上启用并启动httpd服务/允许端口8080:

sudo setsebool -P httpd_read_user_content 1
sudo systemctl enable httpd
sudo systemctl start httpd
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

Test the webserver:

测试网络服务器:

curl localhost:8080

A successful curl should look like this:

成功的卷曲应如下所示:

nuc9如何进bios nuc进入bios方法_python_25

(Download the openshift-installer and oc client:)

SSH to the okd4-services VM

SSH到okd4-services VM

To download the latest oc client and openshift-install binaries, you need to use an existing version of the oc client.

要下载最新的oc客户端和openshift-install二进制文件,您需要使用oc客户端的现有版本。

Download the 4.5 version of the oc client and openshift-install from the OKD releases page. Example:

从OKD版本页面下载4.5版本的oc客户端并进行openshift-install。 例:

cd
wget https://github.com/openshift/okd/releases/download/4.5.0-0.okd-2020-07-29-070316/openshift-client-linux-4.5.0-0.okd-2020-07-29-070316.tar.gz
wget https://github.com/openshift/okd/releases/download/4.5.0-0.okd-2020-07-29-070316/openshift-install-linux-4.5.0-0.okd-2020-07-29-070316.tar.gz

Extract the okd version of the oc client and openshift-install:

提取oc客户端的okd版本并进行openshift-install:

tar -zxvf openshift-client-linux-4.5.0-0.okd-2020-07-29-070316.tar.gz
tar -zxvf openshift-install-linux-4.5.0-0.okd-2020-07-29-070316.tar.gz

Move the kubectl, oc, and openshift-install to /usr/local/bin and show the version:

将kubectl,oc和openshift-install移至/ usr / local / bin并显示版本:

sudo mv kubectl oc openshift-install /usr/local/bin/
oc version
openshift-install version

The latest and recent releases are available at https://origin-release.svc.ci.openshift.org

最新版本和最新版本可在https://origin-release.svc.ci.openshift.org上获得。

(Setup the openshift-installer:)

In the install-config.yaml, you can either use a pull-secret from RedHat or the default of “{“auths”:{“fake”:{“auth”: “bar”}}}” as the pull-secret.

在install-config.yaml中,您可以使用RedHat的Pull-secret,也可以使用默认的“ {{auths”:{“ fake”:{“ auth”:“ bar”}}}””作为Pull-secret 。

Generate an SSH key if you do not already have one.

如果还没有SSH密钥,请生成一个。

ssh-keygen

Create an install directory and copy the install-config.yaml file:

创建一个安装目录并复制install-config.yaml文件:

cd
mkdir install_dir
cp okd4-snc-hyperv/install-config.yaml ./install_dir

Edit the install-config.yaml in the install_dir and add your ssh key. Backup the install-config.yaml as it will be removed when generating the manifests:

在install_dir中编辑install-config.yaml并添加您的ssh密钥。 备份install-config.yaml,因为它将在生成清单时将其删除:

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_26

vim ./install_dir/install-config.yaml
cp ./install_dir/install-config.yaml ./install_dir/install-config.yaml.bak

Generate the Kubernetes manifests for the cluster, ignore the warning:

生成集群的Kubernetes清单,忽略警告:

openshift-install create manifests --dir=install_dir/

Now you can create the ignition-configs:

现在,您可以创建点火配置:

openshift-install create ignition-configs --dir=install_dir/

Note: If you reuse the install_dir, make sure it is empty. Hidden files are created after generating the configs, and they should be removed before you use the same folder on a 2nd attempt.

注意:如果重用install_dir,请确保其为空。 隐藏文件是在生成配置后创建的,在您尝试第二次使用同一文件夹之前,应将其删除。

(Host ignition and Fedora CoreOS files on the webserver:)

Create okd4 directory in /var/www/html:

在/ var / www / html中创建okd4目录:

sudo mkdir /var/www/html/okd4

Copy the install_dir contents to /var/www/html/okd4 and set permissions:

将install_dir内容复制到/ var / www / html / okd4并设置权限:

sudo cp -R install_dir/* /var/www/html/okd4/
sudo chown -R apache: /var/www/html/
sudo chmod -R 755 /var/www/html/

Test the webserver:

测试网络服务器:

curl localhost:8080/okd4/metadata.json

Download the Fedora CoreOS bare-metal bios image and sig files and shorten the file names:

下载Fedora CoreOS裸机bios映像和sig文件,并缩短文件名:

cd /var/www/html/okd4/
sudo wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/32.20200715.3.0/x86_64/fedora-coreos-32.20200715.3.0-metal.x86_64.raw.xz
sudo wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/32.20200715.3.0/x86_64/fedora-coreos-32.20200715.3.0-metal.x86_64.raw.xz.sig
sudo mv fedora-coreos-32.20200715.3.0-metal.x86_64.raw.xz fcos.raw.xz
sudo mv fedora-coreos-32.20200715.3.0-metal.x86_64.raw.xz.sig fcos.raw.xz.sig
sudo chown -R apache: /var/www/html/
sudo chmod -R 755 /var/www/html/
(Create bootstrap and master nodes:)

Download the Fedora CoreOS Bare Metal ISO and save it to your Downloads folder.

下载Fedora CoreOS裸机ISO并将其保存到“下载”文件夹中。

The latest stable version at the time of writing is 32.20200715.3.0

撰写本文时,最新的稳定版本是32.20200715.3.0

nuc9如何进bios nuc进入bios方法_leetcode_27

Create two ODK nodes (okd4-bootstrap and okd4-control-plane-1) in the Hyper-V Manager using the CPU and RAM values from the spreadsheet at the abeginning of this post:

在这篇文章的开头,使用电子表格中的CPU和RAM值在Hyper-V管理器中创建两个ODK节点(okd4-bootstrap和okd4-control-plane-1):

okd4-bootstrap: (okd4-bootstrap:)

Open the Hyper-V Manager and create a new Virtual Machine.

打开Hyper-V管理器并创建一个新的虚拟机。

nuc9如何进bios nuc进入bios方法_windows_06

Choose a name for the VM and select the location.

选择虚拟机的名称,然后选择位置。

nuc9如何进bios nuc进入bios方法_python_29

Choose Generation 2.

选择第二代。

nuc9如何进bios nuc进入bios方法_leetcode_30

Use the Default settings for “Assign Memory” we will edit this later.

使用“分配内存”的默认设置,我们将在以后进行编辑。

nuc9如何进bios nuc进入bios方法_leetcode_09

Select the OKD4-NATSwitch connection.

选择OKD4-NATSwitch连接。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_32

Create a virtual hard disk. I used the defaults.

创建一个虚拟硬盘。 我使用默认值。

nuc9如何进bios nuc进入bios方法_leetcode_33

Select to “Install … from a bootable image file” and Browse to your Fedora CoreOS ISO. Then click finish.

选择“从可引导映像文件安装…”,然后浏览至Fedora CoreOS ISO。 然后单击完成。

nuc9如何进bios nuc进入bios方法_java_34

Edit the VM by selecting the VM and click on Settings …

通过选择VM并单击Settings来编辑VM。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_35

Edit the Boot order to HD, DVD, Network. Disable Secure Boot. Increase the Virtual Processors to 4.

将启动顺序编辑为HD,DVD,网络。 禁用安全启动。 将虚拟处理器增加到4。

nuc9如何进bios nuc进入bios方法_java_36

Edit the Memory to a Min of 512MB and Max of 4096 MB

编辑内存,最小为512MB,最大为4096 MB

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_37

Next create the okd4-control-plane-1 VM.

接下来,创建okd4-control-plane-1 VM。

okd4-control-plane-1 (okd4-control-plane-1)

Create the okd4-control-plane-1 VM using the same steps as the okd4-bootstrap VM with the exception of increasing the CPUs to 4 or higher and the Memory to 16384 MB.

使用与okd4-bootstrap虚拟机相同的步骤创建okd4-control-plane-1虚拟机,除了将CPU增加到4个或更高,并将内存增加到16384 MB。

nuc9如何进bios nuc进入bios方法_java_38

You should end up with the following VMs:

您应该以以下虚拟机结束:

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_39

(Setting static DHCP leases:)

Power on the odk4-bootstrap VM and okd4-control-plane-1 nodes, go to the VM settings, Network Adapter, Advanced Features, and note the Mac Addresses.

打开odk4-bootstrap VM和okd4-control-plane-1节点的电源,转到VM设置,“网络适配器”,“高级功能”,并记下Mac地址。

nuc9如何进bios nuc进入bios方法_windows_40

Update the hardware ethernet address for both nodes.

更新两个节点的硬件以太网地址。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_41

Restart the dhcpd services on the okd4-services node.

在okd4-services节点上重新启动dhcpd服务。

sudo systemctl restart dhcpd
(Start the bootstrap process:)

Reset the VM and allow it to boot.

重置虚拟机并使其启动。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_42

Verify it booted with the correct IP address:

验证它是否使用正确的IP地址启动:

nuc9如何进bios nuc进入bios方法_leetcode_43

Download the ignition file and start the installer using the bootstrap.ign

下载点火文件并使用bootstrap.ign启动安装程序

curl -O http://192.168.200.10:8080/okd4/bootstrap.ign
sudo coreos-installer install /dev/sda --ignition-file ./bootstrap.ign

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_44

Once the install has completed, Power off the VM and Eject the iso.

安装完成后,关闭虚拟机电源并弹出iso。

nuc9如何进bios nuc进入bios方法_python_45

Start the VM. If successful the bootstrap process has begun.

启动虚拟机。 如果成功,则引导过程已开始。

nuc9如何进bios nuc进入bios方法_leetcode_46

(Starting the control-plane-1 node:)

Repeat the same steps from the bootstrap node with the exception of using the master.ign

从引导节点重复相同的步骤,但使用master.ign除外

curl -O http://192.168.200.10:8080/okd4/bootstrap.ign
sudo coreos-installer install /dev/sda --ignition-file ./master.ign

nuc9如何进bios nuc进入bios方法_leetcode_47

Once the install has completed, Power off the VM and Eject the iso.

安装完成后,关闭虚拟机电源并弹出iso。

nuc9如何进bios nuc进入bios方法_python_45

Start the VM.

启动虚拟机。

The control-plane will appear to show an error until the bootstrap progresses. This is normal, just be patient.

在引导程序进行之前,控制面板将显示错误。 这是正常现象,请耐心等待。

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_49

(Monitor the bootstrap installation:)

You can monitor the bootstrap process from the okd4-services node:

您可以从okd4-services节点监视引导过程:

openshift-install --dir=install_dir/ wait-for bootstrap-complete --log-level=debug

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_50

Once the bootstrap process is complete, which can take upwards of 30 minutes, you can shutdown your bootstrap node. Now is a good time to edit the /etc/haproxy/haproxy.cfg, comment out the bootstrap node, and reload the haproxy service.

引导过程完成后(可能需要30分钟以上),您可以关闭引导节点。 现在是编辑/etc/haproxy/haproxy.cfg,注释掉引导节点并重新加载haproxy服务的好时机。

sudo sed -i '/ okd4-bootstrap /s/^/#/' /etc/haproxy/haproxy.cfg
sudo systemctl reload haproxy
(Login to the cluster and check the status:)

Now that the control-plane node is online, you should be able to login with the oc client. Use the following commands to log in and check the status of your cluster:

现在,控制平面节点已联机,您应该能够使用oc客户端登录。 使用以下命令登录并检查集群的状态:

export KUBECONFIG=~/install_dir/auth/kubeconfig
oc whoami
oc get nodes

nuc9如何进bios nuc进入bios方法_java_51

nuc9如何进bios nuc进入bios方法_windows_52

Check the status of the cluster operators.

检查集群操作员的状态。

oc get clusteroperators

nuc9如何进bios nuc进入bios方法_windows_53

Once the console operator is available login to the web console.Get your kubeadmin password from the install_dir/auth folder:

控制台操作员可用后,登录Web控制台。从install_dir / auth文件夹中获取kubeadmin密码:

cat install_dir/auth/kubeadmin-password

nuc9如何进bios nuc进入bios方法_windows_54

Open your web browser to https://console-openshift-console.apps.lab.okd.local/ and login as kubeadmin with the password from above:

打开您的Web浏览器到https://console-openshift-console.apps.lab.okd.local/,然后以kubeadmin的身份使用上述密码登录:

nuc9如何进bios nuc进入bios方法_leetcode_55

The cluster status may still say upgrading, and it continues to finish the installation.

群集状态可能仍显示升级,并且继续完成安装。

nuc9如何进bios nuc进入bios方法_java_56

(Persistent Storage:)

We need to create some persistent storage for our registry before we can complete this project. Let’s configure our okd4-services VM as an NFS server and use it for persistent storage.

在完成此项目之前,我们需要为注册表创建一些持久性存储。 让我们将okd4-services VM配置为NFS服务器,并将其用于持久性存储。

Login to your okd4-services VM and begin to set up an NFS server. The following commands install the necessary packages, enable services, and configure file and folder permissions.

登录到okd4-services VM并开始设置NFS服务器。 以下命令将安装必要的程序包,启用服务以及配置文件和文件夹权限。

sudo dnf install -y nfs-utils
sudo systemctl enable nfs-server rpcbind
sudo systemctl start nfs-server rpcbind
sudo mkdir -p /var/nfsshare/registry
sudo chmod -R 777 /var/nfsshare
sudo chown -R nobody:nobody /var/nfsshare

Create an NFS Export

创建NFS导出

Add this line in the new /etc/exports file “/var/nfsshare 192.168.200.0/24(rw,sync,no_root_squash,no_all_squash,no_wdelay)”

在新的/ etc / exports文件中添加此行“ / var / nfsshare 192.168.200.0/24(rw,sync,no_root_squash,no_all_squash,no_wdelay)”

echo '/var/nfsshare 192.168.200.0/24(rw,sync,no_root_squash,no_all_squash,no_wdelay)' | sudo tee /etc/exports

nuc9如何进bios nuc进入bios方法_leetcode_57

Restart the nfs-server service and add firewall rules:

重新启动nfs-server服务并添加防火墙规则:

sudo setsebool -P nfs_export_all_rw 1
sudo systemctl restart nfs-server
sudo firewall-cmd --permanent --zone=public --add-service mountd
sudo firewall-cmd --permanent --zone=public --add-service rpc-bind
sudo firewall-cmd --permanent --zone=public --add-service nfs
sudo firewall-cmd --reload
(Registry configuration:)

Create a persistent volume on the NFS share. Use the registry_py.yaml in okd4_files folder from the git repo:

在NFS共享上创建一个持久卷。 从git repo使用okd4_files文件夹中的registry_py.yaml:

oc create -f okd4-snc-hyperv/registry_pv.yaml
oc get pv

nuc9如何进bios nuc进入bios方法_windows_58

Edit the image-registry operator:

编辑图像注册运算符:

oc edit configs.imageregistry.operator.openshift.io

Change the managementState: from Removed to Managed. Under storage: add the pvc: and claim: blank to attach the PV and save your changes automatically:

将managementState:从“已删除”更改为“托管”。 在存储下:添加pvc:并声明:空白以附加PV并自动保存更改:

managementState: Managedstorage:
    pvc:
      claim:

nuc9如何进bios nuc进入bios方法_windows_59

Check your persistent volume, and it should now be claimed:

检查您的持久卷,现在应该声明它:

oc get pv

nuc9如何进bios nuc进入bios方法_java_60

Check the export size, and it should be zero. In the next section, we will push to the registry, and the file size should not be zero.

检查导出大小,该大小应为零。 在下一节中,我们将推送到注册表,并且文件大小不应为零。

du -sh /var/nfsshare/registry

nuc9如何进bios nuc进入bios方法_windows_61

In the next section, we will create a WordPress project and push it to the registry. After the push, the NFS export should show 200+ MB.

在下一节中,我们将创建一个WordPress项目并将其推送到注册表。 推送后,NFS导出应显示200+ MB。

(Create WordPress Project:)

Create a new OKD project.

创建一个新的OKD项目。

oc new-project wordpress-test

nuc9如何进bios nuc进入bios方法_java_62

Create a new app using the centos php73 s2i image from docker hub and use the WordPress GitHub repo for the source. Expose the service to create a route.

使用来自docker hub的centos php73 s2i映像创建一个新应用,并将WordPress GitHub存储库用作源。 公开服务以创建路线。

oc new-app centos/php-73-centos7~https://github.com/WordPress/WordPress.git
oc expose svc/wordpress

nuc9如何进bios nuc进入bios方法_nuc9如何进bios_63

Create a new app using the centos7 MariaDB image with some environment variables:

使用带有一些环境变量的centos7 MariaDB映像创建一个新应用程序:

oc new-app centos/mariadb-103-centos7 --name mariadb --env MYSQL_DATABASE=wordpress --env MYSQL_USER=wordpress --env MYSQL_PASSWORD=wordpress

nuc9如何进bios nuc进入bios方法_leetcode_64

Open the OpenShift console and browse to the WordPress-test project. Once the WordPress image is built and ready, it will be dark blue like the MariaDB instance show here:

打开OpenShift控制台并浏览到WordPress测试项目。 构建并准备好WordPress图像后,它将变为深蓝色,如以下MariaDB实例所示:

nuc9如何进bios nuc进入bios方法_python_65

Click on the WordPress object and click on the route to open it in your web browser:

单击WordPress对象,然后单击路由以在Web浏览器中将其打开:

nuc9如何进bios nuc进入bios方法_windows_66

You should see the WordPress setup config, click Let’s Go.

您应该看到WordPress设置配置,单击“我们开始”。

nuc9如何进bios nuc进入bios方法_leetcode_67

Fill in the database, username, password, and database host as pictured and run the installation:

如图所示,填写数据库,用户名,密码和数据库主机,然后运行安装:

nuc9如何进bios nuc进入bios方法_leetcode_68

Fill out the welcome information and click Install WordPress.

填写欢迎信息,然后单击“安装WordPress”。

nuc9如何进bios nuc进入bios方法_java_69

Log in, and you should have a working WordPress installation:

登录,您应该已经可以正常使用WordPress安装:

nuc9如何进bios nuc进入bios方法_leetcode_70

nuc9如何进bios nuc进入bios方法_python_71

nuc9如何进bios nuc进入bios方法_leetcode_72

Check the size of your NFS export on the okd4-services VM. It should be around 300MB in size.

检查okd4-services VM上NFS导出的大小。 它的大小应为300MB左右。

du -sh /var/nfsshare/registry/

nuc9如何进bios nuc进入bios方法_windows_73

You have just verified your persistent volume is working.

您刚刚验证了持久卷是否正常工作。

(HTPasswd Setup:)

The kubeadmin is a temporary user. The easiest way to set up a local user is with htpasswd.

kubeadmin是临时用户。 设置本地用户的最简单方法是使用htpasswd。

cd
cd okd4-snc-hyperv
htpasswd -c -B -b users.htpasswd testuser testpassword

nuc9如何进bios nuc进入bios方法_python_74

Create a secret in the openshift-config project using the users.htpasswd file you generated:

使用您生成的users.htpasswd文件在openshift-config项目中创建一个秘密:

oc create secret generic htpass-secret --from-file=htpasswd=users.htpasswd -n openshift-config

Add the identity provider.

添加身份提供者。

oc apply -f htpasswd_provider.yaml

nuc9如何进bios nuc进入bios方法_leetcode_75

Logout of the OpenShift Console. Then select htpasswd_provider and login with testuser and testpassword credentials.

注销OpenShift控制台。 然后选择htpasswd_provider并使用testuser和testpassword凭据登录。

nuc9如何进bios nuc进入bios方法_leetcode_76

nuc9如何进bios nuc进入bios方法_windows_77

If you visit the Administrator page you should see no projects:

如果您访问“管理员”页面,则应该看不到任何项目:

nuc9如何进bios nuc进入bios方法_leetcode_78

Give yourself cluster-admin access, and the projects should immediately populate:

授予自己群集管理员访问权限,然后项目应立即填充:

oc adm policy add-cluster-role-to-user cluster-admin testuser

Your user should now have cluster-admin level access:

您的用户现在应具有集群管理员级别的访问权限:

nuc9如何进bios nuc进入bios方法_python_79

(Congrats! You have created an OKD Single Node Cluster!)

Hopefully, you have created an OKD single node cluster and learned a few things along the way. At this point, you should have a decent basis to tinker with OKD and continue to learn.

希望您已经创建了一个OKD单节点集群,并在此过程中学到了一些东西。 在这一点上,您应该有一个良好的基础来修改OKD并继续学习。

Here are some resources available to help you along your journey:

以下是一些可用于帮助您的旅程的资源:

To report issues, use the OKD Github Repo: https://github.com/openshift/okd

要报告问题,请使用OKD Github存储库: https : //github.com/openshift/okd

For support check out the #openshift-users channel on k8s Slack

要获得支持,请查看k8s Slack上的#openshift-users频道

The OKD Working Group meets bi-weekly to discuss the development and next steps. The meeting schedule and location are tracked in the openshift/community repo.

OKD工作组每两周开会一次,讨论开发情况和后续步骤。 在openshift /社区回购中跟踪会议的时间表和位置。

Google group for okd-wg: https://groups.google.com/forum/#!forum/okd-wg

okd-wg的Google网上论坛: https ://groups.google.com/forum/#!forum / okd-wg

翻译自: https://itnext.io/okd-4-5-single-node-cluster-on-windows-10-using-hyper-v-3ffb7b369245

okd3.11