阿里云k8s服务简单手动部署

通过阿里云镜像库简单部署应用

1、创建自己的应用镜像(假设创建了 example:latest 镜像)

2、docker 登录阿里云镜像库:

   docker login --username=<youName> registry.cn-hangzhou.aliyuncs.com[镜像地址]

3、输入密码:

4、在本地执行

    docker tag example:latest registry.cn-hangzhou.aliyuncs.com/piglet-test/example:latest
    docker push registry.cn-hangzhou.aliyuncs.com/piglet-test/example:latest

5、本地切换 namespace 并创建应用

    kubens <namspace_name>                 // 使用 kubens 的前提是得安装它,Github上有源码  [ 传送门:https://github.com/ahmetb/kubectx ]
    kubectl run <deployment_name> --image=registry.cn-hangzhou.aliyuncs.com/<images_namespace>/example:latest --port=<服务对外的接口>

使用镜像使用下面其中一条去做,6 用于没有创建应用,7 用于更新已有应用的镜像

6、给deployment添加拉取镜像的权限:在yaml文件中添加

    kubectl edit deployment <deployment_name>  // 先执行此条命令,再在弹出的编辑框中添加如下内容
    
    imagePullSecrets:
    - name: aliyun-secret
    
    kubectl expose deployment <deployment_name> --port=<应用对外暴露的端口>     // 暴露服务

7、更新镜像命令

    kubectl set image deploy/<deployment_name> <deployment_name>=<image_name>:<tag>

猜你喜欢

转载自www.cnblogs.com/enWelcomeToMyBlogs/p/10172016.html