Last active
October 2, 2020 10:30
-
-
Save rgielen/3a5044c3f82690c5ae8caee04ff31ea6 to your computer and use it in GitHub Desktop.
This is a small script to patch a MicroK8s deployment with activated container registry add-on to accept the external facing IP address of the host as a valid insecure registry target.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use Skaffold and other tools for k8s development, the external IP should consistently be used when refferring to an image in a private registry. | |
# To be able to do this in MicroK8s, one need to add the external IP to the accepted insecure registries | |
# See https://microk8s.io/docs/registry-private | |
# | |
# This script does automatic patching for this usecase. | |
# | |
# Apply directly from Guthub Gist on the MicroK8s host: | |
# source <(curl https://gist.githubusercontent.com/rgielen/3a5044c3f82690c5ae8caee04ff31ea6/raw/d5ba473f8de7282827da5bca224143d619834ce2/microk8s-patch-insecure-registries.sh) | |
# | |
# For Mac / Windows you must enter the MicroK8s VM first, e.g. multipass exec microk8s-vm bash | |
MYIP=$(hostname -I | awk '{print $1}') | |
sudo patch -b /var/snap/microk8s/current/args/containerd-template.toml <<EOF | |
--- containerd-template-original.toml 2020-10-02 11:21:15.091385322 +0200 | |
+++ containerd-template.toml 2020-10-02 11:20:50.693904699 +0200 | |
@@ -76,3 +76,6 @@ | |
endpoint = ["https://registry-1.docker.io", ] | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:32000"] | |
endpoint = ["http://localhost:32000"] | |
+ [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${MYIP}:32000"] | |
+ endpoint = ["http://${MYIP}:32000"] | |
+ | |
EOF | |
sudo microk8s stop | |
sudo microk8s start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment