Skip to content

Instantly share code, notes, and snippets.

@jefferyb
Created January 19, 2022 04:03
Show Gist options
  • Save jefferyb/75f9f41cf14e6e4feae30d65584af108 to your computer and use it in GitHub Desktop.
Save jefferyb/75f9f41cf14e6e4feae30d65584af108 to your computer and use it in GitHub Desktop.
Configure podman to work with insecure registries... Using MicroK8s’ built-in registry

How to configure podman to work with insecure registries

Working with MicroK8s’ built-in registry

$ microk8s enable registry

# or if you want to specify the amount of storage to be added. E.g., to use 40Gi:
$ microk8s enable registry:size=40Gi

Install & Setup podman

# install some dependencies
apt-get update -y
apt-get install curl wget gnupg2 -y

# source your Ubuntu release and add the Podman repository
source /etc/os-release
sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"

# download and add the GPG key
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | apt-key add -

# update the repository and install Podman
apt-get update -qq -y
apt-get -qq --yes install podman

# some quick test to verify the install
podman --version
podman info

# Create a file, /etc/containers/registries.conf.d/myregistry.conf
cat > /etc/containers/registries.conf.d/myregistry.conf <<EOF
[[registry]]
location = "localhost:32000"
insecure = true

EOF

# Build image
podman build . -t localhost:32000/example:latest

# Push image to your insecure local registry 
podman push localhost:32000/example:latest

Use our new image

At this point we are ready for kubectl apply -f to deploy with our image:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
  labels:
    app: example
spec:
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: localhost:32000/example:latest
        ports:
        - containerPort: 80
@ujjwalpatil
Copy link

can you please also mentioned, how to add multiple insecure registries? I can find correct format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment