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:

  1. 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)
  2. Install the KVM/libvirt virtualization software
  3. Install Vagrant
  4. Download Red Hat Container Tools and the Vagrant box for Red Hat Enterprise Linux.
  5. Install additional Vagrant plugins to support Red Hat Subscription Management and other features.
  6. Bring up the Vagrant box using a Vagrantfile.

4.1. Prerequisites

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

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

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.

  1. 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).
  2. 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 -
    Copy to Clipboard Toggle word wrap
  3. 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
    Copy to Clipboard Toggle word wrap

    In the above examples, replace variant with server or workstation, 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.

  4. 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
    Copy to Clipboard Toggle word wrap
  5. 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
    Copy to Clipboard Toggle word wrap

    On a Red Hat Enterprise Linux system:

    # yum -y update
    Copy to Clipboard Toggle word wrap
  6. Install and initialize virtualization software: KVM and libvirt.

    On a Fedora system:

    # dnf install @Virtualization
    Copy to Clipboard Toggle word wrap

    On a Red Hat Enterprise Linux system:

    # yum groupinstall -y "Virtualization Host"
    Copy to Clipboard Toggle word wrap
  7. Launch the libvirt daemon and configure it to start at boot.

    # systemctl start libvirtd
    # systemctl enable libvirtd
    Copy to Clipboard Toggle word wrap
  8. Install Vagrant and other required packages, including the vagrant-registration and vagrant-libvirt plugins:

    On a Fedora system:

    # dnf install vagrant vagrant-libvirt vagrant-libvirt-doc vagrant-registration rubygem-ruby-libvirt
    Copy to Clipboard Toggle word wrap

    On a Red Hat Enterprise Linux system:

    # yum install sclo-vagrant1 sclo-vagrant1-vagrant-libvirt \
         sclo-vagrant1-vagrant-libvirt-doc sclo-vagrant1-vagrant-registration
    Copy to Clipboard Toggle word wrap
  9. 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
    Copy to Clipboard Toggle word wrap

    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
    Copy to Clipboard Toggle word wrap

    The following is the contents of the newly created /etc/polkit-1/rules.d/10-vagrant-libvirt.rules rule for reference, or if you prefer to add it by hand.

    /*
     * Allow users in vagrant group to manage libvirt without authentication.
     * Copy this file to /usr/share/polkit-1/rules.d/ to activate.
     */
    polkit.addRule(function(action, subject) {
      if ((action.id == "org.libvirt.unix.manage"
        || action.id == "org.libvirt.unix.monitor")
        && subject.isInGroup("vagrant")) {
        return polkit.Result.YES;
      }
    });
    Copy to Clipboard Toggle word wrap
  10. Restart the libvirt and PolicyKit services for the changes to take effect:

    # systemctl restart libvirtd
    # systemctl restart polkit
    Copy to Clipboard Toggle word wrap
  11. Check your user name, then become root to add your user name to the vagrant group.

    $ echo $USER
    $ su -
    Password: *****
    # usermod -a -G vagrant <username>
    Copy to Clipboard Toggle word wrap

    Note that you need to log out and back in for the change to your group membership to take affect.

  12. 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
    Copy to Clipboard Toggle word wrap

    If you get an RPC: timed out error 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.

  13. Exit from the root shell:

    # exit
    Copy to Clipboard Toggle word wrap

That completes the list of steps that need to be performed as root.

4.3. Setting Up CDK Software Components

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.

  1. 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
    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.c1023
    Copy to Clipboard Toggle word wrap
  2. 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
    Copy to Clipboard Toggle word wrap

    On a Fedora system (Vagrant Software Collection is not required):

    $ vagrant global-status
    Copy to Clipboard Toggle word wrap

    The global-status command should produce a message that says there are no active Vagrant environments on this computer.

  3. 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)
    Note

    The download page also offers Vagrant .box files formatted for other virtualization platforms, such as VirtualBox. You only need to download the .box image 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.

  4. Unzip the ZIP file you downloaded in your home directory. This should create the ~/cdk subdirectory:

    $ cd
    $ unzip ~/Downloads/cdk*.zip
    Copy to Clipboard Toggle word wrap

    At this point, review the included README files to familiarize yourself with Red Hat Container Tools and to find out if there have been any changes since this installation guide was published. The README file associated with the rhel-ose Vagrantfile can be viewed as a plain text file. The plugin README files are are formatted in Markdown. So you might want to use a Markdown reader for a better experience with those files.

  5. Install the plugins contained in the plugins directory. Each plugin is in the form of .gem files 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
    Copy to Clipboard Toggle word wrap
  6. Verify the vagrant-libvirt, vagrant-registration, vagrant-service-manager, and vagrant-sshfs plugins are properly installed by running the following command (note that the vagrant-registration plugin 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):

    $ vagrant plugin list
    vagrant-libvirt (0.0.32, system)
    vagrant-registration (1.2.1)
      - Version Constraint: 1.2.1
    vagrant-service-manager (1.0.1)
      - Version Constraint: 1.0.1
    vagrant-sshfs (1.1.0)
      - Version Constraint: 1.1.0
    Copy to Clipboard Toggle word wrap
  7. 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
    Copy to Clipboard Toggle word wrap

    Note that the name you assign to the box using the --name parameter in the above step must correspond to the name used by the Vagrantfile to refer to the box. By default, this is cdkv2 for the Vagrantfiles provided with the CDK.

    Verify that the box is installed:

    $ vagrant box list
    Copy to Clipboard Toggle word wrap

    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

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.

Note

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
    Copy to Clipboard Toggle word wrap
  • Start the Single-node Kubernetes setup (rhel-k8s-singlenode-setup) as follows:

    $ cd ~/cdk/components/rhel/misc/rhel-k8s-singlenode-setup/
    $ vagrant up
    Copy to Clipboard Toggle word wrap

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: *******
Copy to Clipboard Toggle word wrap

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
Copy to Clipboard Toggle word wrap

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.
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat