Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Use Vagrant Landrush to add DNS features to your OpenShift CDK Machine

May 27, 2016
Ricardo Martinelli
Related topics:
ContainersKubernetes
Related products:
Red Hat OpenShift Container Platform

Share:

    With the release of the Red Hat Container Development Kit (CDK), it’s been easier to set up a development environment with OpenShift to create, develop and test your own containerized applications, and easier evaluate different CI/CD strategies with Jenkins --- strategies that reflect your team's unique culture.

    However, when you want to access applications by their DNS names, you cannot do so because there is no DNS server pointing to that name. That is, of course, until now!

    Vagrant provides a very nice plugin that can use dnsmasq to create a DNS caching server to provide this access.

    Vagrant Landrush plugin

    The Vagrant Landrush plugin is used to create a small DNS server to redirect traffic to your server. DNS entries are automatically updated as the VMs are created and destroyed by Vagrant.

    This plugin is available in https://github.com/vagrant-landrush/landrush.

    Installing Vagrant Landrush plugin

    Vagrant landrush can be installed with the following command:

    vagrant plugin install landrush

    After that, you can run landrush direclty from vagrant command. To check if landrush is running, you can type the following command:

    vagrant landrush status

    If landrush service is not started just run:

    vagrant landrush start

    And now landrush is running!

    $ vagrant landrush status
    Daemon status: running pid=6841

    Since landrush acts like a DNS server, you can see the DNS records stored in landrush with the following command:

    $ vagrant landrush ls
    2.2.1.10.in-addr.arpa          openshift.cdk.vm
    1.42.17.172.in-addr.arpa       openshift.cdk.vm
    openshift.cdk.vm               10.1.2.2

    Also, you can add the records with the following command:

    vagrant landrush set <fqdn> <ip-address>

    And now you have Vagrant Landrush up and running. Now we need to configure dnsmasq to query for Vagrant Landrush records. You must run the following commands to configure dnsmasq:

    sudo sh -c 'echo "server=/cdk.vm/127.0.0.1#10053" > /etc/dnsmasq.d/vagrant-landrush'

    And dnsmasq will forward all DNS queries related to cdk.vm to Vagrant Landrush process. Although I’m using cdk.vm as the domain name, the default value is vagrant.test, however in the next section I’ll show how to configure your virtual machine to use custom DNS names.

    If you are using the NetworkManager service, you must run the same command, changed slightly for use with NetworkManager:

    sudo sh -c 'echo "server=/cdk.vm/127.0.0.1#10053" > /etc/NetworkManager/vagrant-landrush'

    And you must set the dns auto-configuration to use dnsmasq. To do so, edit /etc/NetworkManager/NetworkManager.conf and set the following values:

    [main]
    plugins=ifcfg-rh,ibft
    dns=dnsmasq

    Configuring your OpenShift CDK machine

    Now you need to add the Vagrant Landrush configuration in the Vagrantfile of your OpenShift CDK Machine. Add the following content to enable Vagrant Landrush:

    config.vm.hostname = "openshift.cdk.vm"
    config.landrush.enabled = true
    config.landrush.host_ip_address = "#{PUBLIC_ADDRESS}"
    config.landrush.tld = "openshift.cdk.vm"
    config.landrush.guest_redirect_dns = false

    This snippet will:

    • Set the hostname to openshift.cdk.vm
    • Enable Vagrant Landrush on the machine
    • Set the IP Address to the same IP assigned to OpenShift CDK Machine (generally the IP address is 10.1.2.2)
    • Set a TLD name to openshift.cdk.vm (that way all DNS names with openshift.cdk.vm suffix will resolve to the same IP address)
    • Proxy all DNS requests

    After this configuration, all you need to do is bring up your OpenShift Virtual Machine with the command vagrant up and you’ll be able to access your OpenShift Machine using the URL https://openshift.cdk.vm:8443.

    What about my OpenShift applications?

    One of the good things about Vagrant Landrush is that it can accept wildcard domains, meaning that anything under the specified TLD can resolve to the Virtual Machine address.

    In this case, everything under openshift.cdk.vm can be resolved to 10.1.2.2 address (which is exactly what we need to resolve DNS names for our applications). However, in the provisioning phase, Vagrant sets OpenShift to use cdk.vm as the routing subdomain, which will create all routes under .cdk.vm and you will need to fix them manually.

    One thing to solve this issue is add some lines in the provision snippet of the Vagrantfile to reconfigure OpenShift to resolve to the correct subdomain:

    config.vm.provision "shell", inline: <<-SHELL
      sudo systemctl enable openshift
      sudo systemctl start openshift</pre>
      sudo sed -i 's/subdomain: <a href="http://openshift.cdk.vm.10.1.2.2.xip.io/subdomain" target="_blank">openshift.cdk.vm.10.1.2.2.xip.<wbr />io/subdomain</a>: openshift.cdk.vm/' /var/lib/openshift/openshift.<wbr />local.config/master/master-<wbr />config.yaml
      sudo systemctl restart openshift SHELL

    With this configuration, all your applications will automatically create a route with a DNS name inside openshift.cdk.vm. Now, enjoy access your applications using a special DNS name!

    Last updated: January 19, 2023

    Recent Posts

    • More Essential AI tutorials for Node.js Developers

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    What’s up next?

     

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue