Difference between revisions of "Microk8s registry"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
Simple build/import script | Simple build/import script | ||
+ | |||
+ | Dockerfile | ||
+ | ``` | ||
+ | FROM alpine | ||
+ | ADD https://github.com/coredns/coredns/releases/download/v1.8.1/coredns_1.8.1_linux_amd64.tgz coredns_1.8.1_linux_amd64.tgz | ||
+ | RUN tar xf coredns_1.8.1_linux_amd64.tgz | ||
+ | ADD https://raw.githubusercontent.com/jeremybusk/share/master/Corefile conf/Corefile | ||
+ | COPY . / | ||
+ | CMD ./coredns -conf Corefile | ||
+ | ``` | ||
+ | |||
+ | build | ||
``` | ``` | ||
#!/usr/bin/env bash | #!/usr/bin/env bash | ||
set -e | set -e | ||
− | name= | + | name=rdns-coredns:jtest1 |
sudo docker build . -t $name | sudo docker build . -t $name | ||
sudo docker save $name > $name.tar | sudo docker save $name > $name.tar | ||
sudo microk8s ctr image import $name.tar | sudo microk8s ctr image import $name.tar | ||
sudo microk8s ctr images ls | grep $name | sudo microk8s ctr images ls | grep $name | ||
+ | ``` | ||
+ | |||
+ | rdns-coredns.yml | ||
+ | ``` | ||
+ | apiVersion: v1 | ||
+ | kind: Service | ||
+ | metadata: | ||
+ | name: rdns-coredns | ||
+ | labels: | ||
+ | run: rdns-coredns | ||
+ | spec: | ||
+ | type: NodePort | ||
+ | ports: | ||
+ | - port: 53 | ||
+ | targetPort: 53 | ||
+ | protocol: TCP | ||
+ | name: dns-tcp | ||
+ | - port: 53 | ||
+ | protocol: UDP | ||
+ | name: dns-udp | ||
+ | selector: | ||
+ | run: rdns-coredns | ||
+ | --- | ||
+ | apiVersion: apps/v1 | ||
+ | kind: Deployment | ||
+ | metadata: | ||
+ | name: rdns-coredns | ||
+ | spec: | ||
+ | selector: | ||
+ | matchLabels: | ||
+ | run: rdns-coredns | ||
+ | replicas: 1 | ||
+ | template: | ||
+ | metadata: | ||
+ | labels: | ||
+ | run: rdns-coredns | ||
+ | spec: | ||
+ | volumes: | ||
+ | - name: secret-volume | ||
+ | secret: | ||
+ | secretName: rdns-coredns-secret | ||
+ | - name: configmap-volume | ||
+ | configMap: | ||
+ | name: rdns-coredns-configmap | ||
+ | containers: | ||
+ | - name: rdns-coredns | ||
+ | # image: rdns-coredns:latest | ||
+ | # image: localhost:32000/rdns-coredns:latest | ||
+ | # image: docker.io/library/rdns-coredns:jtest1 | ||
+ | image: rdns-coredns:jtest1 | ||
+ | ports: | ||
+ | - containerPort: 53 | ||
+ | protocol: UDP | ||
+ | - containerPort: 53 | ||
+ | protocol: TCP | ||
+ | ``` | ||
+ | |||
+ | Let's run a query | ||
+ | ``` | ||
+ | k get pods -o=wide | grep coredns | ||
+ | host google.com <ip address from above> | ||
``` | ``` | ||
Revision as of 19:43, 14 April 2021
Simple build/import script
Dockerfile
FROM alpine ADD https://github.com/coredns/coredns/releases/download/v1.8.1/coredns_1.8.1_linux_amd64.tgz coredns_1.8.1_linux_amd64.tgz RUN tar xf coredns_1.8.1_linux_amd64.tgz ADD https://raw.githubusercontent.com/jeremybusk/share/master/Corefile conf/Corefile COPY . / CMD ./coredns -conf Corefile
build
#!/usr/bin/env bash set -e name=rdns-coredns:jtest1 sudo docker build . -t $name sudo docker save $name > $name.tar sudo microk8s ctr image import $name.tar sudo microk8s ctr images ls | grep $name
rdns-coredns.yml
apiVersion: v1 kind: Service metadata: name: rdns-coredns labels: run: rdns-coredns spec: type: NodePort ports: - port: 53 targetPort: 53 protocol: TCP name: dns-tcp - port: 53 protocol: UDP name: dns-udp selector: run: rdns-coredns --- apiVersion: apps/v1 kind: Deployment metadata: name: rdns-coredns spec: selector: matchLabels: run: rdns-coredns replicas: 1 template: metadata: labels: run: rdns-coredns spec: volumes: - name: secret-volume secret: secretName: rdns-coredns-secret - name: configmap-volume configMap: name: rdns-coredns-configmap containers: - name: rdns-coredns # image: rdns-coredns:latest # image: localhost:32000/rdns-coredns:latest # image: docker.io/library/rdns-coredns:jtest1 image: rdns-coredns:jtest1 ports: - containerPort: 53 protocol: UDP - containerPort: 53 protocol: TCP
Let's run a query
k get pods -o=wide | grep coredns host google.com <ip address from above>
https://microk8s.io/docs/registry-images
https://microk8s.io/docs/registry-built-in
https://microk8s.io/docs/registry-private
sudo vim /var/snap/docker/current/config/daemon.json
"insecure-registries" : ["x.x.x.y:32000"],
sudo microk8s ctr images ls name~='localhost:32000'
sudo microk8s ctr images rm localhost:32000/coredns:latest