Mirantis named a Challenger in 2024 Gartner® Magic Quadrant™ for Container Management  |  Learn More

< BLOG HOME

Getting Started with Docker Enterprise 3.1

image
Docker Enterprise from Mirantis is the fastest way to create modern applications, but despite its power, it's pretty easy to set up and get started. In this article, we're going to assume you've installed Docker Enterprise using the Mirantis Launchpad CLI Tool, get familiar with using the Universal Control Plane to create and manage Kubernetes objects, add an additional node to the cluster, and learn how to access it from the command line.
Let's get started.

Accessing Docker Enterprise Universal Control Plane

The first thing we need to do is initialize the cluster:
  1. When you installed Docker Enterprise with Mirantis Launchpad, you got a message such as:
    INFO[0257] Cluster is now configured. You can access your cluster admin UI at: https://ec2-34-222-249-19.us-west-2.compute.amazonaws.com 
    INFO[0257] You can also download the admin client bundle with the following command: launchpad download-bundle --username <username> --password <password> 
  2. Copy the URL to your browser and access it to get to the login screen.  (You may have to tell it to ignore certificate warnings.)Docker Enterprise Login
  3. Log in using the username and password you specified in your cluster.yaml file, as in:
    apiVersion: launchpad.mirantis.com/v1beta1
    kind: UCP
    metadata:
     name: ucp-kube
    spec:   
     ucp:
        installFlags:
        - --admin-username=admin
        - --admin-password=passw0rd!
        - --default-node-orchestrator=kubernetes                                    
     hosts:
      - address: ec2-34-222-249-19.us-west-2.compute.amazonaws.com
        user: ubuntu
     ...
  4. If you have one, click Upload License and choose your *.lic file, or click Skip For Now.
Congratulations, you now have a functional cluster!Now let's look at accessing the cluster.

Accessing the Kubernetes cluster using UCP

When you run Launchpad, it creates a cluster capable of hosting both Kubernetes and Docker Swarm nodes. In this case, let's look at how to access the cluster using Kubernetes tools.
Follow these steps to use the UI to create and manage individual objects: 
  1. Choose Kubernetes -> + Create to create any type of object using YAML.
  2. In this case, let's create a couple of different objects using the following YAML:
    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      selector:
        app: nginx
      ports:
      - port: 80
        name: http
        targetPort: 80
      - port: 443
        name: https
        targetPort: 80
    ---
    apiVersion: v1
    kind: Pod
    metadata:
      name: rss-site
      labels:
        app: web
    spec:
      containers:
        - name: front-end
          image: nginx
          ports:
            - containerPort: 80
        - name: rss-reader
          image: nickchase/rss-php-nginx:v1
          ports:
            - containerPort: 88
    Enter the YAML in the box, or upload the *.yml file directly. In this case, we're adding the objects to the kube-public namespace.  Choose that as your namespace and click Create
  3. Click Kubernetes -> Namespaces, then highlight kube-public and click Set Context to tell UCP to choose this namespace.
  4. Now choose Kubernetes -> Pods and you'll see the Pod you just created.
  5. You can also use the Actions pulldown to remove objects.
Now let's talk about accessing the cluster using the command line.

Accessing the Docker Enterprise Kubernetes cluster from the CLI

In order to access the Kubernetes cluster from the command line, you will need to do two things:
  1. Install kubectl
  2. Download the client bundle from UCP to set the context and provide credentials
There's no special tool for accessing the Kubernetes cluster, so you can use the normal kubectl install instructions to complete step 1.  Fortunately, step 2 is just as easy.  Follow these instructions:
  1. Click Dashboard and scroll down to find the Docker CLI information box.  
  2. Click the arrow to open the Create and Manage Services Using the CLI dialog box.
  3. Now you'll need to create the client bundle. To do that, click the user profile page link.  This link opens a new tab that enables you to create a new bundle.
  4. Click New Client Bundle and select Generate Client Bundle, then enter a label and click Confirm.
  5. When you click Confirm, the bundle will download automatically. There won't be any dialog box or other indication, but don't panic, it's in your Downloads folder.  On the command line of your local machine (where you downloaded the bundle), you'll want to extract the environment script and execute it.  If you're using Linux, this set of commands is:
    unzip ucp-bundle-admin.zip
    eval "$(<env.sh)"
    Note that this assumes that you're using the admin user; make sure to use the actual filename.
    For Windows, simply unzip the archive and run 
    .\env.cmd
  6. At this point your kubectl client is configured to access the Kubernetes cluster. To test it, type
    $ kubectl get pods -n kube-public
    NAME       READY     STATUS    RESTARTS   AGE
    rss-site   2/2       Running   0          1d
    The first time you run this command, it may take a few seconds to get a response, but you should see the pods we created earlier.
Now that you know how to access the Kubernetes cluster, let's look at adding an additional node to that cluster.

Adding a new node to a Docker Enterprise cluster

The last thing we want to do in this article is to add another node to the cluster so you can see how that is done.  Using Mirantis Launchpad CLI Tool, it's a simple matter of adding the new server to the cluster.yaml file and applying it.  For example, I started with two servers, and now I've added a third:
apiVersion: launchpad.mirantis.com/v1beta1
kind: UCP
metadata:
 name: ucp-kube
spec:   
 ucp:
    installFlags:
    - --admin-username=admin
    - --admin-password=passw0rd!
    - --default-node-orchestrator=kubernetes                                    
 hosts:
  - address: ec2-34-222-249-19.us-west-2.compute.amazonaws.com
    user: ubuntu
    role: manager               
    sshKeyPath: /Users/nchase/Downloads/kaas.pem
  - address: ec2-35-160-242-135.us-west-2.compute.amazonaws.com
    user: ubuntu                
    role: worker
    sshKeyPath: /Users/nchase/Downloads/kaas.pem
  - address: ec2-18-237-127-216.us-west-2.compute.amazonaws.com
    user: ubuntu
    role: worker
    sshKeyPath: /Users/nchase/Downloads/kaas.pem
From there, if we go ahead and re-execute:
launchpad apply
...
INFO[0094] ==> Running phase: Join workers     
INFO[0095] ec2-35-160-242-135.us-west-2.compute.amazonaws.com: already a swarm node 
INFO[0096] ec2-18-237-127-216.us-west-2.compute.amazonaws.com:  This node joined a swarm as a worker. 
INFO[0096] ec2-18-237-127-216.us-west-2.compute.amazonaws.com: joined succesfully 
INFO[0096] ==> Running phase: Close SSH Connection 
INFO[0098] ec2-18-237-127-216.us-west-2.compute.amazonaws.com: SSH connection closed 
INFO[0098] ec2-35-160-242-135.us-west-2.compute.amazonaws.com: SSH connection closed 
INFO[0098] ec2-34-222-249-19.us-west-2.compute.amazonaws.com: SSH connection closed 
INFO[0098] ==> Running phase: UCP cluster info 
INFO[0098] Cluster is now configured. You can access your cluster admin UI at: https://ec2-34-222-249-19.us-west-2.compute.amazonaws.com 
INFO[0098] You can also download the admin client bundle with the following command: launchpad download-bundle --username <username> --password <password> 
As you can see, the new node gets added to the cluster.  You can see that if you choose Shared Resources -> Nodes.
Back on your local machine, where you've downloaded the client bundle, you should now be able to see the new Kubernetes node as well.

Next Steps

At this point, you've got a fully-functional Kubernetes cluster running on Docker Enterprise, and you can do anything you'd normally do with Kubernetes with it. Stay tuned for upcoming tutorials on using Istio Ingress, GPUs, and Windows nodes with Kubernetes, or join us to see them in action. And if you haven't tried Mirantis Launchpad CLI Tool yet, now is the time!

Choose your cloud native journey.

Whatever your role, we’re here to help with open source tools and world-class support.

GET STARTED