Skip to content

Latest commit

 

History

History

09_Use_Pull_Secret

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Difficulty: 2/5

Summary:

This exercise will teach you how to use an account to download containers images from your registry.

In this exercise, we will do it for dockerhub.

Prerequisites

  • A Kubernetes cluster
  • A docker account

Exercise

  1. Verify your account with docker cli

    Answer
    1. Launch command docker login
    2. Answer to username and password requests
    3. You should be successfully logged in.

  2. Create a secret with type docker-registry with CLI (look at kubernetes documentation)

    Answer
    1. Launch command kubectl create secret docker-registry <name of your secret> --docker-username=<your-name> --docker-password=<your-pword> -n <your namespace>

  3. Inspect YAML code from your secret with kubectl get command

    Answer
    1. Launch command kubectl get secret <your secret> -n <your namespace> --output=yaml

  4. Create a simple manifest to create :

    • A pod with image gautierleblanc/nke-labs:latest
    • Using your secret for the download from dockerhub registry
    Answer
    1. Create this manifest
      apiVersion: v1
      kind: Pod
      metadata:
        name: my-test
      spec:
        containers:
          - name: private-reg-container
            image: gautierleblanc/nke-labs:latest
            imagePullPolicy: Always
        imagePullSecrets:
          - name: <your secret>
    2. Apply it with command kubectl apply -f <your manifest> -n <your namespace>
    3. Your pod will use your secret to download the image from the registry

Takeover

ImagePullSecret is a great way to use authentication on registries. It can be very useful for test, when you use public registries limiting number of anonymous download per IP.