Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 4. Installing Red Hat Container Development Kit on Fedora or Red Hat Enterprise Linux
To prepare to run the CDK on a Fedora or Red Hat Enterprise Linux system, an overview of the steps are:
- If you have not already done so, install the host operating system (in this case, we tested both Fedora 23 Workstation and Red Hat Enterprise Linux 7.2 Server)
- Install the KVM/libvirt virtualization software
- Install Vagrant
- Download Red Hat Container Tools and the Vagrant box for Red Hat Enterprise Linux.
- Install additional Vagrant plugins to support Red Hat Subscription Management and other features.
- Bring up the Vagrant box using a Vagrantfile.
4.1. Prerequisites Link kopierenLink in die Zwischenablage kopiert!
To run the CDK on a Fedora or Red Hat Enterprise Linux system, you need:
- A 64-bit machine with a minimum of 4 GB of RAM. At least 2 GB should be reserved for the CDK, with 3-4GB reserved for the CDK being more reasonable if you plan to run multiple virtual machines. The Kubernetes Vagrantfiles defines 1 GB of disk space while the OSE Vagrantfile asks for up to 3 GB of disk space.
- A minimum of 3 GB of free disk space for virtual machine images. Note that during the setup process, you will need to be able to store multiple copies of each of the virtual machine images.
- Adequate Internet connectivity to download 1—2 GB of software.
- An available Red Hat Enterprise Linux Server subscription with support for Red Hat Enterprise Linux Developer Suite. Note that Red Hat Enterprise Linux subscriptions with self-support do not have access to all of the necessary software for CDK in all environments.
4.2. Installing Virtualization and CDK Components Link kopierenLink in die Zwischenablage kopiert!
Vagrant is used to run a Red Hat Enterprise Linux virtual machine with all necessary components for CDK included in it. Virtualization will be provided by using the native Linux Kernel-based Virtual machine (KVM) hypervisor and libvirt, an API and a set of tools for managing virtual machines.
A Vagrant plugin is installed to enable using libvirt as one of Vagrant virtualization providers. If you are not familiar with KVM and libvirt, see the Fedora Virtualization Getting Started Guide.
You need root privilege to install the necessary software and perform configuration on your Fedora or Red Hat Enterprise Linux development host. Once Vagrant and libvirt are installed and correctly configured, you will complete the preparation as a regular, non-root user. You will be able to start, stop, and configure Vagrant boxes using your regular user account.
Take care to use the same user ID for running Vagrant. Since Vagrant stores configuration components, such as plugins and downloaded box images, in the user’s home directory (~/.vagrant.d), if you change to a different user ID, you will need to repeat the steps that install Vagrant plugins and boxes.
Do not run Vagrant when you are logged in as the root user, to avoid creating problems with file permissions.
4.2.1. Installing Software and Configuring the Host System Link kopierenLink in die Zwischenablage kopiert!
The following steps need to be completed as root to install the virtualization software and the necessary configuration on your Red Hat Enterprise Linux or Fedora host system.
- If you have not already done so, install Fedora Workstation or Red Hat Enterprise Linux (Server or Workstation) directly on hardware (or on a virtual machine that is set to act as a hypervisor).
Open a terminal session and use the su - command to gain root privileges to install Vagrant and configure the development host for running Vagrant boxes.
su -
$ su -Copy to Clipboard Copied! Toggle word wrap Toggle overflow Subscribe your host system (Red Hat Enterprise Linux only). If your host is a Red Hat Enterprise Linux system, you must subscribe that host system (using your Red Hat username and password) and enable several software repositories. (These commands are not required for Fedora systems.) For example:
subscription-manager register --auto-attach --username=user --password=passwd subscription-manager repos --enable rhel-variant-rhscl-7-rpms subscription-manager repos --enable rhel-7-variant-optional-rpms
# subscription-manager register --auto-attach --username=user --password=passwd # subscription-manager repos --enable rhel-variant-rhscl-7-rpms # subscription-manager repos --enable rhel-7-variant-optional-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the above examples, replace
variantwithserverorworkstation, depending on which variant of Red Hat Enterprise Linux you are using. If the Red Hat Software Collections repository is not available, you might need to subscribe with a specific pool ID that includes that repository.Enable the CentOS SCLO repository (Red Hat Enterprise Linux only). Because Vagrant is not officially packaged for Red Hat Enterprise Linux, it needs to be installed using a Software Collection packaged for CentOS. (This is not required for Fedora systems.) To enable the repository containing the Vagrant Software Collection, run the following command:
yum-config-manager --add-repo=http://mirror.centos.org/centos-7/7/sclo/x86_64/sclo/ echo "gpgcheck=0" >> /etc/yum.repos.d/mirror.centos.org_centos-7_7_sclo_x86_64_sclo_.repo
# yum-config-manager --add-repo=http://mirror.centos.org/centos-7/7/sclo/x86_64/sclo/ # echo "gpgcheck=0" >> /etc/yum.repos.d/mirror.centos.org_centos-7_7_sclo_x86_64_sclo_.repoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Update your system. If a new kernel is installed during the update, reboot your system before proceeding with the remaining steps. This step is different on Red Hat Enterprise Linux and Fedora.
On a Fedora system:
dnf -y update
# dnf -y updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow On a Red Hat Enterprise Linux system:
yum -y update
# yum -y updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install and initialize virtualization software: KVM and libvirt.
On a Fedora system:
dnf install @Virtualization
# dnf install @VirtualizationCopy to Clipboard Copied! Toggle word wrap Toggle overflow On a Red Hat Enterprise Linux system:
yum groupinstall -y "Virtualization Host"
# yum groupinstall -y "Virtualization Host"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Launch the libvirt daemon and configure it to start at boot.
systemctl start libvirtd systemctl enable libvirtd
# systemctl start libvirtd # systemctl enable libvirtdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install Vagrant and other required packages, including the
vagrant-registrationandvagrant-libvirtplugins:On a Fedora system:
dnf install vagrant vagrant-libvirt vagrant-libvirt-doc vagrant-registration rubygem-ruby-libvirt
# dnf install vagrant vagrant-libvirt vagrant-libvirt-doc vagrant-registration rubygem-ruby-libvirtCopy to Clipboard Copied! Toggle word wrap Toggle overflow On a Red Hat Enterprise Linux system:
yum install sclo-vagrant1 sclo-vagrant1-vagrant-libvirt \ sclo-vagrant1-vagrant-libvirt-doc sclo-vagrant1-vagrant-registration# yum install sclo-vagrant1 sclo-vagrant1-vagrant-libvirt \ sclo-vagrant1-vagrant-libvirt-doc sclo-vagrant1-vagrant-registrationCopy to Clipboard Copied! Toggle word wrap Toggle overflow Allow your regular user ID to start and stop Vagrant boxes. A PolicyKit rule will be added that allows users in the vagrant group to control VMs through libvirt. The necessary rule is included in one of the vagrant packages you just installed. Run one of the following commands (depending on whether your host is a Red Hat Enterprise Linux or Fedora system) to add the rule on your system:
On a Fedora system:
cp /usr/share/vagrant/gems/doc/vagrant-libvirt-0.0.30/polkit/10-vagrant-libvirt.rules /etc/polkit-1/rules.d
# cp /usr/share/vagrant/gems/doc/vagrant-libvirt-0.0.30/polkit/10-vagrant-libvirt.rules /etc/polkit-1/rules.dCopy to Clipboard Copied! Toggle word wrap Toggle overflow On a Red Hat Enterprise Linux system (note that your version of vagrant-libvirt may be different):
cp /opt/rh/sclo-vagrant1/root/usr/share/vagrant/gems/doc/vagrant-libvirt-*/polkit/10-vagrant-libvirt.rules /etc/polkit-1/rules.d
# cp /opt/rh/sclo-vagrant1/root/usr/share/vagrant/gems/doc/vagrant-libvirt-*/polkit/10-vagrant-libvirt.rules /etc/polkit-1/rules.dCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following is the contents of the newly created
/etc/polkit-1/rules.d/10-vagrant-libvirt.rulesrule for reference, or if you prefer to add it by hand.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the libvirt and PolicyKit services for the changes to take effect:
systemctl restart libvirtd systemctl restart polkit
# systemctl restart libvirtd # systemctl restart polkitCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check your user name, then become root to add your user name to the vagrant group.
echo $USER su - usermod -a -G vagrant <username>
$ echo $USER $ su - Password: ***** # usermod -a -G vagrant <username>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that you need to log out and back in for the change to your group membership to take affect.
If you intend to use NFS for directory sharing, check that the NFS server is available by checking that the nfs-server and rpcbind services are running, and then listing NFS exports:
systemctl status nfs-server systemctl status rpcbind showmount --exports
# systemctl status nfs-server # systemctl status rpcbind # showmount --exportsCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you get an
RPC: timed outerror message, it indicates that Vagrant attempted to use NFS for file synchronization, but it could not establish a connection to the NFS server. If the NFS server and RPC service are running, but the NFS service is not available, try to disable the firewall to see if it is preventing access.The list of NFS exports is empty unless you have previously used NFS and exported some directories. Vagrant automatically adds and removes the necessary exports when you bring a Vagrant box up or halt it.
Exit from the root shell:
exit
# exitCopy to Clipboard Copied! Toggle word wrap Toggle overflow
That completes the list of steps that need to be performed as root.
4.3. Setting Up CDK Software Components Link kopierenLink in die Zwischenablage kopiert!
The remaining steps should be performed under your regular non-root user ID. This should be the same user ID you added to the vagrant group.
Start a Terminal session and verify you are a member of the vagrant group (you may need to log in again to have the new group appear).
grep vagrant /etc/group id
$ grep vagrant /etc/group vagrant:x:978:joe $ id uid=1001(joe) gid=1001(joe) groups=1001(joe),978(vagrant) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the Vagrant Software Collection and verify that things are set up to run Vagrant as a regular, non-root user:
On a Red Hat Enterprise Linux system:
scl enable sclo-vagrant1 bash vagrant global-status
$ scl enable sclo-vagrant1 bash $ vagrant global-statusCopy to Clipboard Copied! Toggle word wrap Toggle overflow On a Fedora system (Vagrant Software Collection is not required):
vagrant global-status
$ vagrant global-statusCopy to Clipboard Copied! Toggle word wrap Toggle overflow The global-status command should produce a message that says there are no active Vagrant environments on this computer.
Download the CDK software components from the Red Hat Product Downloads web site. You must log in to get access to this page. If you are on the right page, you should see "Product Variant: Red Hat Container Development Kit". You need to download the following items:
- Red Hat Container Tools (cdk-2.0.*.zip or later)
- Red Hat Enterprise Linux 7.2 Vagrant box for libvirt (rhel-cdk-kubernetes-7.2*.x86_64.vagrant-libvirt.box or later)
NoteThe download page also offers Vagrant
.boxfiles formatted for other virtualization platforms, such as VirtualBox. You only need to download the.boximage that matches the virtualization you are using — which is libvirt for Red Hat Enterprise Linux or Fedora.The following steps assume you have saved these files in your home directory in
~/Downloads. If you used a different directory, adjust the paths accordingly. You need several gigabytes of free space for the Vagrant box images.Unzip the ZIP file you downloaded in your home directory. This should create the
~/cdksubdirectory:cd unzip ~/Downloads/cdk*.zip
$ cd $ unzip ~/Downloads/cdk*.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow At this point, review the included
READMEfiles to familiarize yourself with Red Hat Container Tools and to find out if there have been any changes since this installation guide was published. TheREADMEfile associated with the rhel-ose Vagrantfile can be viewed as a plain text file. The pluginREADMEfiles are are formatted in Markdown. So you might want to use a Markdown reader for a better experience with those files.Install the plugins contained in the plugins directory. Each plugin is in the form of
.gemfiles that were unpacked from the ZIP file (note that your versions may be different):cd ~/cdk/plugins/ vagrant plugin install \ ./vagrant-registration-1.2.1.gem \ ./vagrant-service-manager-1.0.1.gem \ ./vagrant-sshfs-1.1.0.gem
$ cd ~/cdk/plugins/ $ vagrant plugin install \ ./vagrant-registration-1.2.1.gem \ ./vagrant-service-manager-1.0.1.gem \ ./vagrant-sshfs-1.1.0.gemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the
vagrant-libvirt,vagrant-registration,vagrant-service-manager, and vagrant-sshfs plugins are properly installed by running the following command (note that thevagrant-registrationplugin has already been installed as a separate RPM package in Installing Software, but you can install plugin supplied in the ZIP file so you get the latest version):Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the Red Hat Enterprise Linux Server box to Vagrant. This is the configured virtual machine image that you downloaded in one of the previous steps. (Adjust the command below if your have a newer version of the Vagrant box.) You will be using this for container development and testing.
vagrant box add --name cdkv2 ~/Downloads/rhel-cdk-kubernetes-7.2*.x86_64.vagrant-libvirt.box
$ vagrant box add --name cdkv2 ~/Downloads/rhel-cdk-kubernetes-7.2*.x86_64.vagrant-libvirt.boxCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note that the name you assign to the box using the
--nameparameter in the above step must correspond to the name used by the Vagrantfile to refer to the box. By default, this iscdkv2for the Vagrantfiles provided with the CDK.Verify that the box is installed:
vagrant box list
$ vagrant box listCopy to Clipboard Copied! Toggle word wrap Toggle overflow The box image file will be stored in your home directory under
~/.vagrant.d. You need adequate space there, approximately 3 GB.
4.4. Starting the CDK Vagrant Box in Red Hat Enterprise Linux or Fedora Link kopierenLink in die Zwischenablage kopiert!
With the Vagrant box and Vagrantfiles in place, you are ready to bring up the selected Vagrant box. Your choices of Vagrantfiles are as follows:
- OpenShift (rhel-ose): The OpenShift (rhel-ose) Vagrantfile launches a Red Hat Enterprise Linux server virtual machine (VM) with OpenShift Enterprise running on it. With OpenShift running, you can use either the Web Console from the browser on your desktop or docker, oc, and related commands by logging into the VM. With some additional setup, you can add other tools to access feature in the VM from your host (see Using the CDK for information on how to to access the VM from Eclipse or command line tools from your desktop).
- Kubernetes(rhel-k8s-singlenode-setup): Use the Kubernetes (rhel-k8s-singlenode-setup) Vagrantfile to start a more generic CDK VM. Because OpenShift is not running, you can configure a more basic Kubernetes configuration or use docker directly.
NOTE: Instead of using one of the provided Vagrantfiles, you can copy one of the existing Vagrantfiles and modify it for your own purposes. For example, you might want to use a different IP address if it conflicts with an address on your local network.
Follow these instruction to start up a VM from the selected VM, from the proper Vagrantfile provided in the Red Hat Container Tools ZIP file.
Before you start your CDK Vagrant box, consider reviewing the Vagrantfile to see if there are any settings you want to change. In particular, you might want to configure SSHFS to share a directory between your CDK virtual machine and your local system. See the description of the vagrant-sshfs plugin in the "Using the Red Hat CDK" chapter for information on how to configure this.
Start the OpenShift Enterprise integration (rhel-ose) as follows:
cd ~/cdk/components/rhel/rhel-ose/ vagrant up vagrant provision # If OpenShift fails, repeat this command until it starts
$ cd ~/cdk/components/rhel/rhel-ose/ $ vagrant up $ vagrant provision # If OpenShift fails, repeat this command until it startsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the Single-node Kubernetes setup (rhel-k8s-singlenode-setup) as follows:
cd ~/cdk/components/rhel/misc/rhel-k8s-singlenode-setup/ vagrant up
$ cd ~/cdk/components/rhel/misc/rhel-k8s-singlenode-setup/ $ vagrant upCopy to Clipboard Copied! Toggle word wrap Toggle overflow
At this point, if all is going well, you are asked for a username and password for Red Hat Subscription management in order to register the system and enable downloading of RPM software packages from Red Hat repositories. You have the choice of:
- Registering your Red Hat Enterprise Linux VM now (recommended) or
Registering your Red Hat Enterprise Linux VM later
NOTE: See the Using the CDK chapter for information on obtaining Red Hat Enterprise Linux subscriptions, how registration works with the CDK, and details on why you need to register your system.
To register your system now, enter the username and password you use with the Red Hat Customer Portal.
==> default: Registering box with vagrant-registration…
default: Would you like to register the system now (default: yes)? [y|n] y
default: Subscriber username: <username>
default: Subscriber password: *******
==> default: Registering box with vagrant-registration…
default: Would you like to register the system now (default: yes)? [y|n] y
default: Subscriber username: <username>
default: Subscriber password: *******
You can check whether your Vagrant box is running using the vagrant status command. Note that you must be in the same directory where your Vagrant file is located.
cd ~/cdk/components/rhel/rhel-ose/ vagrant status
$ cd ~/cdk/components/rhel/rhel-ose/
$ vagrant status
If the machine state shows as running, you are ready to start using your CDK. Refer to the following:
- The Using the CDK chapter will help you understand the different Vagrantfiles, plugins and interfaces needed to work with your CDK. It also discusses special topics, such as other ways to register your Red Hat Enterprise Linux virtual machines.
- The Getting Started with Container Development Kit guide provides information on getting started with container development.