温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

go-admin如何部署到istio平台

发布时间:2021-02-23 13:42:32 来源:亿速云 阅读:157 作者:小新 栏目:编程语言

小编给大家分享一下go-admin如何部署到istio平台,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

部署istio环境参考istio官网

创建独立命名空间go-admin,自动注入 sidecar

kubectl create namespace go-admin
kubectl label namespace go-admin istio-injection=enabled

创建配置configmap

kubectl create configmap settings-admin --from-file=config/settings.yml -n go-admin

pv及pvc根据自己到需求调整

kubectl apply -f storage.yml -n go-admin#storage.yml---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: go-admin
  namespace: go-admin
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: "1Mi"
  volumeName:
  storageClassName: nfs-csi

部署后端服务v1版本dev分支

配置
kubectl apply -f deploy.yml -n go-admin# deploy.yml---
apiVersion: v1
kind: Service
metadata:
  name: go-admin
  namespace: go-admin
  labels:
    app: go-admin
    service: go-admin
spec:
  ports:
  - port: 8000
    name: http
    protocol: TCP
  selector:
    app: go-admin
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: go-admin-v1
  namespace: go-admin
  labels:
    app: go-admin
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: go-admin
      version: v1
  template:
    metadata:
      labels:
        app: go-admin
        version: v1
    spec:
      containers:
      - name: go-admin
        image: registry.cn-shanghai.aliyuncs.com/go-admin-team/go-admin:v1.2.2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8000
        volumeMounts:
        - name: go-admin
          mountPath: /temp
        - name: go-admin
          mountPath: /static
        - name: go-admin-config
          mountPath: /config/
          readOnly: true
      volumes:
      - name: go-admin
        persistentVolumeClaim:
          claimName: go-admin
      - name: go-admin-config
        configMap:
          name: settings-admin
---

创建前端nginx配置configmap

kubectl create configmap nginx-frontend --from-file=default.conf -n go-admin#default.confserver {
  listen       80;
  listen  [::]:80;
  server_name  localhost;

  #charset koi8-r;
  #access_log  /var/log/nginx/host.access.log  main;

  location / {
      root   /usr/share/nginx/html;
      index  index.html index.htm;
  }}

部署前端服务v1版本dev分支

kubectl apply -f deploy.yml# deploy.yml---
apiVersion: v1
kind: Service
metadata:
  name: go-admin-ui
  namespace: go-admin
  labels:
    app: go-admin-ui
    service: go-admim-ui
spec:
  ports:
    - port: 80
      name: http
      protocol: TCP
  selector:
    app: go-admin-ui
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: go-admin-ui-v1
  namespace: go-admin
  labels:
    app: go-admin-ui
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: go-admin-ui
      version: v1
  template:
    metadata:
      labels:
        app: go-admin-ui
        version: v1
    spec:
      containers:
        - name: go-admin-ui
          image: registry.cn-shanghai.aliyuncs.com/go-admin-team/go-admin-ui:v1.2.2
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
          volumeMounts:
            - name: frontendconf
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
              readOnly: true
      volumes:
        - name: frontendconf
          configMap:
            name: nginx-frontend
---

创建dr

kubectl apply -f destination-go-admin.yaml -n go-admin#destination-go-admin.yamlapiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: go-admin-ui
  namespace: go-admin
spec:
  host: go-admin-ui
  subsets:
  - name: v1
    labels:
      version: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: go-admin
  namespace: go-admin
spec:
  host: go-admin
  subsets:
  - name: v1
    labels:
      version: v1

创建gateway和vs(域名改成实际域名)

kubectl apply -f go-admin-gateway.yml -n go-admin#go-admin-gateway.yml---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: go-admin-gateway
  namespace: go-admin
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "go-admin.xxxxxx.com"---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: go-admin-ui
  namespace: go-admin
spec:
  hosts:
  - "*"
  gateways:
  - go-admin-gateway
  http:
  - match:
    - uri:
        prefix: /api
    - uri:
        prefix: /login
    route:
    - destination:
        host: go-admin
        subset: v1
        port:
          number: 8000
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: go-admin-ui
        subset: v1
        port:
          number: 80

看完了这篇文章,相信你对“go-admin如何部署到istio平台”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI