minikube的相关信息
创建基于阿里云的私有镜像仓库的secret
这个kubia是kubernetes in action这本书里的,我把这个image推送到了自己在阿里上的私有仓库里,访问私有仓库需要secrets
kubectl create secret docker-registry aliyun --docker-server=registry.cn-hangzhou.aliyuncs.com --docker-username=登陆名字 --docker-password=登陆密码 --docker-email=邮箱
另一种创建secret的方式,这种在minikube关闭后会消失,官方的secrets文档
kubectl create secret generic aliyunsecret \
--from-file=.dockerconfigjson=/root/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
查看secrets
~# kubectl get secrets
NAME TYPE DATA AGE
aliyun kubernetes.io/dockerconfigjson 1 9d
yaml
apiVersion: v1
kind: Pod
metadata:
name: kubia
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/仓库名字/kubia
name: kubiacontainers
ports:
- containerPort: 8080
protocol: TCP
name: http
imagePullSecrets:
- name: aliyun
根据yaml创建pod
kubectl apply -f aliyun-pod.yaml
端口转发
需要安装socat
~# kubectl port-forward kubia 8888:8080
Forwarding from 127.0.0.1:8888 -> 8080
Forwarding from [::1]:8888 -> 8080
访问应用
~# curl http://localhost:8888
You’ve hit kubia