CentOS7虚拟机搭建K8S-Docker环境部署ruoyi微服务 - 2 docker部署

1.Master安装jdk,redis,nginx,nacos,docker,node安装docker方法从前,打包生成镜像

2. 搭建docker私有仓库

docker pull registry:2
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --name myregistry registry:2

将制作的镜像推送到docker的私有仓库

docker tag auth:latest localhost:5000/auth:1.0
docker push localhost:5000/auth:1.0

docker tag gateway:latest localhost:5000/gateway:1.0
docker push localhost:5000/gateway:1.0

docker tag system:latest localhost:5000/system:1.0
docker push localhost:5000/system:1.0

3. k8s创建命名空间及secret

创建命名空间sun
kubectl create namespace sun

kubectl create secret docker-registry regcred --docker-server=sun-server ip:5000 --docker-username=root --docker-password=root --docker-email=xxx@126.com -n sun

建立以下auth.yaml,在/usr/local/ruoyi目录下,其他类似

---
apiVersion: v1
kind: Service
metadata:
  name: auth-service
  namespace: sun
  labels:
    app: auth-service
spec:
  type: NodePort
  ports:
  - port: 9200
    targetPort: 9200
    protocol: TCP
    name: http
  selector:
    app: auth-pod
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: auth-deployment
  namespace: sun
spec:
  selector:
    matchLabels:
      app: auth-pod
  replicas: 1
  template:
    metadata:
      labels:
        app: auth-pod
    spec:
      containers:
      - name: auth-container
        image: localhost:5000/auth:1.0
        ports:
        - containerPort: 9200

node 安装wget,执行以下代码

yum -y install wget
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-1.19.10-1.el7_4.x86_64.rpm
rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest

创建pod,完成

kubectl create  -f /usr/local/ruoyi/auth.yaml -n sun

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值