Getting Started with Docker Enterprise 3.1
Let's get started.
Accessing Docker Enterprise Universal Control PlaneThe first thing we need to do is initialize the cluster:
- When you installed Docker Enterprise with Mirantis Launchpad, you got a message such as:
INFO 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 You can also download the admin client bundle with the following command: launchpad download-bundle --username <username> --password <password>
- 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.)
- 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 ...
- If you have one, click Upload License and choose your *.lic file, or click Skip For Now.
Accessing the Kubernetes cluster using UCPWhen 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:
- Choose Kubernetes -> + Create to create any type of object using YAML.
- 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: 88Enter 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.</span
- Click Kubernetes -> Namespaces, then highlight kube-public and click Set Context to tell UCP to choose this namespace.
- Now choose Kubernetes -> Pods and you'll see the Pod you just created.
- You can also use the Actions pulldown to remove objects.
Accessing the Docker Enterprise Kubernetes cluster from the CLIIn order to access the Kubernetes cluster from the command line, you will need to do two things:
- Install kubectl
- Download the client bundle from UCP to set the context and provide credentials
- Click Dashboard and scroll down to find the Docker CLI information box.
- Click the arrow to open the Create and Manage Services Using the CLI dialog box.
- 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.
- Click New Client Bundle and select Generate Client Bundle, then enter a label and click Confirm.
- 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
- 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 1dThe 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.
Adding a new node to a Docker Enterprise clusterThe 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.pemFrom there, if we go ahead and re-execute:
launchpad apply ... INFO ==> Running phase: Join workers INFO ec2-35-160-242-135.us-west-2.compute.amazonaws.com: already a swarm node INFO ec2-18-237-127-216.us-west-2.compute.amazonaws.com: This node joined a swarm as a worker. INFO ec2-18-237-127-216.us-west-2.compute.amazonaws.com: joined succesfully INFO ==> Running phase: Close SSH Connection INFO ec2-18-237-127-216.us-west-2.compute.amazonaws.com: SSH connection closed INFO ec2-35-160-242-135.us-west-2.compute.amazonaws.com: SSH connection closed INFO ec2-34-222-249-19.us-west-2.compute.amazonaws.com: SSH connection closed INFO ==> Running phase: UCP cluster info INFO 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 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.