MicroK8s : Registry を有効にする2020/08/04 |
MicroK8s ビルトイン の Registry を有効にする場合は以下のように設定します。
|
[1] | プライマリーノードで、ビルトイン Registry を有効にします。 有効にすると、[kube-proxy] が [0.0.0.0:32000] で待ち受け状態となります。 |
# バックエンドストレージサイズ 30G で registry を有効にする # サイズ指定しない場合のデフォルトは 20G # サイズ指定は MicroK8s 1.18.3 以降で可能 root@dlp:~# microk8s enable registry:size=30Gi Enabling default storage class deployment.apps/hostpath-provisioner created storageclass.storage.k8s.io/microk8s-hostpath created serviceaccount/microk8s-hostpath created clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created Storage will be available soon Enabling the private registry Applying registry manifest namespace/container-registry created persistentvolumeclaim/registry-claim created deployment.apps/registry created service/registry created The registry is enabled The size of the persistent volume is 30Gi # [registry] pod が起動する root@dlp:~# microk8s kubectl get pods -A NAMESPACE NAME READY STATUS RESTARTS AGE container-registry registry-7cf58dcdcc-bbdz2 1/1 Running 1 127m kube-system coredns-588fd544bf-g9frb 1/1 Running 2 20h kube-system dashboard-metrics-scraper-59f5574d4-67tjr 1/1 Running 2 20h kube-system hostpath-provisioner-75fdc8fccd-nzld5 1/1 Running 1 127m kube-system kubernetes-dashboard-6d97855997-p5hzj 1/1 Running 2 20h kube-system metrics-server-c65c9d66-zzdl6 1/1 Running 2 20h |
[2] | Registry 有効後は、通常通りの方法で使用可能です。 |
root@dlp:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest 9d2a0c6e5b57 12 days ago 166MB # タグ付けしてプッシュ root@dlp:~# docker tag 9d2a0c6e5b57 localhost:32000/httpd:registry root@dlp:~# docker push localhost:32000/httpd The push refers to repository [localhost:32000/httpd] 4e6cfff37f35: Pushed 6078e6411b20: Pushed a292ec64305a: Pushed 38b213d315e5: Pushed 95ef25a32043: Pushed registry: digest: sha256:015cb5ae6306ed3d96d21409fd9cd6303666edc93f5b6e26b97af00cf3a9045b size: 1367root@dlp:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest 9d2a0c6e5b57 12 days ago 166MB localhost:32000/httpd registry 9d2a0c6e5b57 12 days ago 166MB |
[3] | 他ホストから利用する場合は [insecure registry] に登録します。 |
root@node02:~#
vi /etc/docker/daemon.json { "insecure-registries" : ["10.0.0.30:32000"] }
root@node02:~#
root@node02:~# systemctl restart docker
docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 8cf1bfb43ff5 12 days ago 132MBroot@node02:~# docker tag 8cf1bfb43ff5 10.0.0.30:32000/nginx:registry root@node02:~# docker push 10.0.0.30:32000/nginx The push refers to repository [10.0.0.30:32000/nginx] 98b4c818e603: Pushed 1698c1b7e3e6: Pushed 227442bb48dc: Pushed d899691659b0: Pushed 95ef25a32043: Pushed registry: digest: sha256:deb724a427ea79face617392a5a471fdcb4cdb57f971ee6b7e492b90fecb199f size: 1362root@node02:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 10.0.0.30:32000/nginx registry 8cf1bfb43ff5 12 days ago 132MB nginx latest 8cf1bfb43ff5 12 days ago 132MB |
Sponsored Link |