Manage and deploy private images

Manage and deploy private images

Mirantis offers its own image registry, MSR (Mirantis Secure Registry), which you can use to store and manage the images that you deploy to your cluster. This topic illustrates the use of Kubernetes orchestrator to push an image to MSR and later deploy that image to your cluster.

Open the MSR web UI

  1. In the MKE web UI, click Admin Settings.

  2. In the left pane, click Mirantis Secure Registry.

  3. In the Installed MSRs section, note the URL of your cluster’s MSR instance.

  4. In a new browser tab, enter the URL to open the MSR web UI.

Create an image repository

  1. In the MSR web UI, click Repositories.

  2. Click New Repository, and in the Repository Name field, enter “wordpress”.

  3. Click Save to create the repository.

Push an image to MSR

Instead of building an image from scratch, we’ll pull the official WordPress image from Docker Hub, tag it, and push it to MSR. Once that WordPress version is in MSR, only authorized users can change it.

CLI access to a licensed installation is required to push images to MSR.

  1. Pull the public WordPress image from Docker Hub:

    docker pull wordpress
    
  2. Tag the image, using the IP address or DNS name of your MSR instance:

    docker tag wordpress:latest <msr-url>:<port>/admin/wordpress:latest
    
  3. Log in to an MKE manager node.

  4. Push the tagged image to MSR:

    docker image push <msr-url>:<port>/admin/wordpress:latest
    

Confirm the image push

In the MSR web UI, confirm that the wordpress:latest image is store in your MSR instance.

  1. In the MSR web UI, click Repositories.

  2. Click wordpress to open the repo.

  3. Click Images to view the stored images.

  4. Confirm that the latest tag is present.

You’re ready to deploy the wordpress:latest image into production.

Deploy the private image to MKE

With the WordPress image stored in MSR, you can deploy the image to a Kubernetes cluster with a simple Deployment object:

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: wordpress-deployment
spec:
  selector:
    matchLabels:
      app: wordpress
  replicas: 2
  template:
    metadata:
      labels:
        app: wordpress
    spec:
      containers:
      - name: wordpress
        image: <msr-url>:<port>/admin/wordpress:latest
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: wordpress-service
  labels:
    app: wordpress
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30081
  selector:
    app: wordpress

The Deployment object’s YAML specifies your MSR image in the pod template spec: image: <msr-url>:<port>/admin/wordpress:latest. Also, the YAML file defines a NodePort service that exposes the WordPress application, so it’s accessible from outside the cluster.

  1. Open the MKE web UI, and in the left pane, click Kubernetes.

  2. Click Create to open the Create Kubernetes Object page.

  3. In the Namespace dropdown, select default.

  4. In the Object YAML editor, paste the Deployment object’s YAML.

  5. Click Create. When the Kubernetes objects are created, the Load Balancers page opens.

  6. Click wordpress-service, and in the details pane, find the Ports section.

  7. Click the URL to open the default WordPress home page.