日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

k8s 安装redis-operator并以operator方式部署redis-standalone redis-cluster集群完整操作记录

發布時間:2025/1/21 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 k8s 安装redis-operator并以operator方式部署redis-standalone redis-cluster集群完整操作记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝redis-operator

install.sh

[root@linux:redis-operator]$ cat install.sh #!/usr/bin/env bash# This script is for installing OLM from a GitHub releaseset -edefault_base_url=https://github.com/operator-framework/operator-lifecycle-manager/releases/downloadif [[ ${#@} -lt 1 || ${#@} -gt 2 ]]; thenecho "Usage: $0 version [base_url]"echo "* version: the github release version"echo "* base_url: the github base URL (Default: $default_base_url)"exit 1 fiif kubectl get deployment olm-operator -n openshift-operator-lifecycle-manager > /dev/null 2>&1; thenecho "OLM is already installed in a different configuration. This is common if you are not running a vanilla Kubernetes cluster. Exiting..."exit 1 firelease="$1" base_url="${2:-${default_base_url}}" url="${base_url}/${release}" namespace=olmif kubectl get deployment olm-operator -n ${namespace} > /dev/null 2>&1; thenecho "OLM is already installed in ${namespace} namespace. Exiting..."exit 1 fikubectl apply -f "${url}/crds.yaml" kubectl wait --for=condition=Established -f "${url}/crds.yaml" kubectl apply -f "${url}/olm.yaml"# wait for deployments to be ready kubectl rollout status -w deployment/olm-operator --namespace="${namespace}" kubectl rollout status -w deployment/catalog-operator --namespace="${namespace}"retries=30 until [[ $retries == 0 ]]; donew_csv_phase=$(kubectl get csv -n "${namespace}" packageserver -o jsonpath='{.status.phase}' 2>/dev/null || echo "Waiting for CSV to appear")if [[ $new_csv_phase != "$csv_phase" ]]; thencsv_phase=$new_csv_phaseecho "Package server phase: $csv_phase"fiif [[ "$new_csv_phase" == "Succeeded" ]]; thenbreakfisleep 10retries=$((retries - 1)) doneif [ $retries == 0 ]; thenecho "CSV \"packageserver\" failed to reach phase succeeded"exit 1 fikubectl rollout status -w deployment/packageserver --namespace="${namespace}"

redis-operator.yaml

[root@linux:redis-operator]$ cat redis-operator.yaml apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata:name: my-redis-operatornamespace: operators spec:channel: stablename: redis-operatorsource: operatorhubio-catalogsourceNamespace: olm

Install redis-operator on Kubernetes

  • Install Operator Lifecycle Manager (OLM), a tool to help manage the Operators running on your cluster.

    $ curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.19.1/install.sh | bash -s v0.19.1
  • Install the operator by running the following command:What happens when I execute this command?

    $ kubectl create -f https://operatorhub.io/install/redis-operator.yaml

    This Operator will be installed in the “operators” namespace and will be usable from all namespaces in the cluster.

  • After install, watch your operator come up using next command.

    $ kubectl get csv -n operators

    To use it, checkout the custom resource definitions (CRDs) introduced by this operator to start using it.

  • 部署redis

    redis-standalone.yml

    [root@linux:redis-operator]$ cat redis-single.yml apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: Redis metadata:name: redis-standalone spec:kubernetesConfig:image: 'quay.io/opstree/redis:v6.2.5'imagePullPolicy: IfNotPresentresources:requests:cpu: 101mmemory: 128Milimits:cpu: 101mmemory: 128MiserviceType: ClusterIPstorage:volumeClaimTemplate:spec:accessModes:- ReadWriteOnceresources:requests:storage: 1GiredisExporter:enabled: falseimage: 'quay.io/opstree/redis-exporter:1.0'

    redis-cluster.yml

    [root@linux:redis-operator]$ cat redis-cluster.yml apiVersion: redis.redis.opstreelabs.in/v1beta1 kind: RedisCluster metadata:name: redis-cluster spec:clusterSize: 3kubernetesConfig:image: 'quay.io/opstree/redis:v6.2.5'imagePullPolicy: IfNotPresentresources:requests:cpu: 101mmemory: 128Milimits:cpu: 101mmemory: 128MiserviceType: ClusterIPredisExporter:enabled: falseimage: 'quay.io/opstree/redis-exporter:1.0'redisLeader:serviceType: ClusterIPredisFollower:serviceType: ClusterIPstorage:volumeClaimTemplate:spec:accessModes:- ReadWriteOnceresources:requests:storage: 1Gi

    執行結果:

    [root@linux:redis-operator]$ kubectl get po NAME READY STATUS RESTARTS AGE redis-cluster-follower-0 1/1 Running 0 98s redis-cluster-follower-1 1/1 Running 0 67s redis-cluster-follower-2 1/1 Running 0 35s redis-cluster-leader-0 1/1 Running 0 98s redis-cluster-leader-1 1/1 Running 0 67s redis-cluster-leader-2 1/1 Running 0 35s

    進入集群,-c集群模式連接:

    bash-4.4# redis-cli -c 127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> set k1 v1 -> Redirected to slot [12706] located at 172.17.0.13:6379 OK 172.17.0.13:6379> 172.17.0.13:6379> 172.17.0.13:6379> get k1 "v1" 172.17.0.13:6379>

    參考鏈接:https://operatorhub.io/operator/redis-operator

    總結

    以上是生活随笔為你收集整理的k8s 安装redis-operator并以operator方式部署redis-standalone redis-cluster集群完整操作记录的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。