高进波的博客 数据库 redisInsight on k8s

redisInsight on k8s

redisInsight on k8s post thumbnail image

介绍

RedisInsight是官方的一个web客户端
https://docs.redis.com/latest/ri/installing/install-k8s/

部署-持久化方式

vi redisinsight.yaml
# RedisInsight service with name 'redisinsight-service'
apiVersion: v1
kind: Service
metadata:
  name: redisinsight-service       # name should not be 'redisinsight'
                                   # since the service creates
                                   # environment variables that
                                   # conflicts with redisinsight
                                   # application's environment
                                   # variables `REDISINSIGHT_HOST` and
                                   # `REDISINSIGHT_PORT`
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8001
  selector:
    app: redisinsight

# RedisInsight deployment with name 'redisinsight'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redisinsight #deployment name
  labels:
    app: redisinsight #deployment label
spec:
  replicas: 1 #a single replica pod
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: redisinsight #which pods is the deployment managing, as defined by the pod template
  template: #pod template
    metadata:
      labels:
        app: redisinsight #label for pod/s
    spec:
      volumes:
        - name: db
          persistentVolumeClaim:
            claimName: redisinsight-pv-claim
      initContainers:
        - name: init
          image: busybox
          command:
            - /bin/sh
            - '-c'
            - |
                            chown -R 1001 /db
          resources: {}
          volumeMounts:
            - name: db
              mountPath: /db
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      containers:
        - name:  redisinsight #Container name (DNS_LABEL, unique)
          image: redislabs/redisinsight:1.14.0 #repo/image
          imagePullPolicy: IfNotPresent #Always pull image
          volumeMounts:
          - name: db #Pod volumes to mount into the container's filesystem. Cannot be updated.
            mountPath: /db
          ports:
          - containerPort: 8001 #exposed container port and protocol
            protocol: TCP

kubectl -n web apply -f redisinsight.yaml

istio网关配置

vi  istio-redisinsight.yaml 
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: redisinsight-gateway
spec:
  # The selector matches the ingress gateway pod labels.
  # If you installed Istio using Helm following the standard documentation, this would be "istio=ingress"
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "redisinsight.gaojinbo.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: redisinsight-vs
spec:
  hosts:
  - "redisinsight.gaojinbo.com"
  gateways:
  - redisinsight-gateway
  http:
  - route:
    - destination:
        host: redisinsight-service 
        port:
          number: 80

kubectl -n web apply -f istio-redisinsight.yaml

验证

curl -I -H"host:redisinsight.gaojinbo.com" 192.168.2.21:31795
HTTP/1.1 200 OK
cache-control: max-age=0, no-cache, no-store, must-revalidate, private
content-length: 640
content-type: text/html; charset=utf-8
cross-origin-opener-policy: same-origin
date: Mon, 18 Dec 2023 09:14:05 GMT
expires: Mon, 18 Dec 2023 09:14:05 GMT
referrer-policy: same-origin
server: istio-envoy
set-cookie: csrftoken=pTTegMvLRIQM1Lz3532VkLGDu9x9zcyN; expires=Mon, 16 Dec 2024 09:14:05 GMT; Max-Age=31449600; Path=/; SameSite=Lax
set-cookie: sessionid=68ngiwg78hjp5b33m4sas4mr01joozpi; expires=Mon, 01 Jan 2024 09:14:05 GMT; HttpOnly; Max-Age=1209600; Path=/; SameSite=Lax
vary: Cookie
x-content-type-options: nosniff
x-frame-options: DENY
x-envoy-upstream-service-time: 450

Related Post