OCP的operator——(4)用户任务:使用Operator创建etcd集群

news2024/12/24 2:16:51

文章目录

  • 环境
  • 在namespace中安装Operator
    • 先决条件
    • 使用Web console从OperatorHub安装
    • 删除
  • 使用CLI从OperatorHub安装
  • 从已安装的Operator创建应用
    • 使用Operator创建etcd集群
    • 报错
      • 从web console debug
      • 从命令行debug
      • 分析
  • 参考

环境

  • RHEL 9.3
  • Red Hat OpenShift Local 2.32

在namespace中安装Operator

先决条件

打开web console:

$ crc console
Opening the OpenShift Web Console in the default browser...

会自动打开浏览,访问web console:

在这里插入图片描述
注:如果不想自动打开浏览器,则可以加上 --url 选项:

$ crc console --url
https://console-openshift-console.apps-crc.testing

然后手工复制URL,并从浏览器里访问。

查看用户名密码:

$ crc console --credentials
To login as a regular user, run 'oc login -u developer -p developer https://api.crc.testing:6443'.
To login as an admin, run 'oc login -u kubeadmin -p cWwas-FvXBW-rTjsi-eECwX https://api.crc.testing:6443'

使用 developer 登录web console:

在这里插入图片描述

切换到“Administrator”视角,可见,在“Operators”下,只有“Installed Operators”(当前没有安装Operator)。

这是因为 developer 用户没有安装Operator的权限,需要赋权才行。

简略起见,就不赋权了。退出登录,然后使用 kubeadmin 帐号登录:

在这里插入图片描述

可见,在“Operators”下多了“OperatorHub”子菜单,并且“Installed Operators”里显示了“Package Server”。

使用Web console从OperatorHub安装

点击“OperatorHub”,搜索“etcd”:

在这里插入图片描述
点击搜索结果里的“etcd”,弹出对话框,如下:

在这里插入图片描述

点击左上角“Install”按钮,如下:

  • Update channel:默认为 singlenamespace-alpha
  • Version:默认为 0.9.4
  • Installation mode:默认为 A specific namespace on the cluster
  • Installed namespace:选择 my-etcd ,这是自己创建的project(namespace),若还没有创建,则创建一下
  • Update approval:默认为 Automatic

在这里插入图片描述

最后,点击“Install”按钮,安装Operator。

大约一两分钟,就安装好了:

在这里插入图片描述

回到“Installed Operators”,可见在 my-etec project下,出现了etcd Operator:

在这里插入图片描述

点击可以查看详情:

在这里插入图片描述

注:在命令行,可查看相应的CSV:

$ oc get csv -n my-etcd
NAME                  DISPLAY   VERSION   REPLACES              PHASE
etcdoperator.v0.9.4   etcd      0.9.4     etcdoperator.v0.9.2   Succeeded

删除

点击右侧三个点,选择“Uninstall Operator”:

在这里插入图片描述

使用CLI从OperatorHub安装

查看当前身份:

$ oc whoami
kubeadmin

查看OperatorHub中集群可用的Operator列表:

$ oc get packagemanifests -n openshift-marketplace
NAME                                               CATALOG               AGE
forklift-operator                                  Community Operators   34d
debezium-operator                                  Community Operators   34d
pcc-operator                                       Certified Operators   34d
......
etcd                                               Community Operators   34d
......

检查所需Operator,以验证其支持的安装模式和可用频道:

$ oc describe packagemanifests etcd -n openshift-marketplace
Name:         etcd
Namespace:    openshift-marketplace
Labels:       catalog=community-operators
              catalog-namespace=openshift-marketplace
              operatorframework.io/arch.amd64=supported
              operatorframework.io/os.linux=supported
              provider=CNCF
              provider-url=
Annotations:  <none>
API Version:  packages.operators.coreos.com/v1
Kind:         PackageManifest
Metadata:
  Creation Timestamp:  2024-01-10T10:34:13Z
Spec:
Status:
  Catalog Source:               community-operators
  Catalog Source Display Name:  Community Operators
  Catalog Source Namespace:     openshift-marketplace
  Catalog Source Publisher:     Red Hat
  Channels:
    Current CSV:  etcdoperator.v0.6.1
    Current CSV Desc:
      Annotations:
        Capabilities:           Full Lifecycle
        Description:            etcd is a distributed key value store providing a reliable way to store data across a cluster of machines.
        Tectonic - Visibility:  ocs
      Apiservicedefinitions:
      Customresourcedefinitions:
        Owned:
          Description:   Represents a cluster of etcd nodes.
          Display Name:  etcd Cluster
          Kind:          EtcdCluster
          Name:          etcdclusters.etcd.database.coreos.com
          Version:       v1beta2
      Description:       etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines. It’s open-source and available on GitHub. etcd gracefully handles leader elections during network partitions and will tolerate machine failure, including the leader. Your applications can read and write data into etcd.
A simple use-case is to store database connection details or feature flags within etcd as key value pairs. These values can be watched, allowing your app to reconfigure itself when they change. Advanced uses take advantage of the consistency guarantees to implement database leader elections or do distributed locking across a cluster of workers.

_The etcd Open Cloud Service is Public Alpha. The goal before Beta is to fully implement backup features._

### Reading and writing to etcd

Communicate with etcd though its command line utility `etcdctl` or with the API using the automatically generated Kubernetes Service.

[Read the complete guide to using the etcd Open Cloud Service](https://coreos.com/tectonic/docs/latest/alm/etcd-ocs.html)

### Supported Features
**High availability**
Multiple instances of etcd are networked together and secured. Individual failures or networking issues are transparently handled to keep your cluster up and running.
**Automated updates**
Rolling out a new etcd version works like all Kubernetes rolling updates. Simply declare the desired version, and the etcd service starts a safe rolling update to the new version automatically.
**Backups included**
Coming soon, the ability to schedule backups to happen on or off cluster.

      Display Name:  etcd
      Install Modes:
        Supported:  true
        Type:       OwnNamespace
        Supported:  true
        Type:       SingleNamespace
        Supported:  false
        Type:       MultiNamespace
        Supported:  true
        Type:       AllNamespaces
      Keywords:
        etcd
        key value
        database
        coreos
        open source
      Links:
        Name:  Blog
        URL:   https://coreos.com/etcd
        Name:  Documentation
        URL:   https://coreos.com/operators/etcd/docs/latest/
        Name:  etcd Operator Source Code
        URL:   https://github.com/coreos/etcd-operator
      Maintainers:
        Email:   support@coreos.com
        Name:    CoreOS, Inc
      Maturity:  alpha
      Provider:
        Name:  CoreOS, Inc
      Related Images:
        quay.io/coreos/etcd-operator@sha256:bd944a211eaf8f31da5e6d69e8541e7cada8f16a9f7a5a570b22478997819943
      Version:  0.6.1
    Entries:
      Name:       etcdoperator.v0.6.1
      Version:    0.6.1
    Name:         alpha
    Current CSV:  etcdoperator.v0.9.4-clusterwide
    Current CSV Desc:
      Annotations:
        Alm - Examples:  [
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdCluster",
    "metadata": {
      "name": "example",
      "annotations": {
        "etcd.database.coreos.com/scope": "clusterwide"
      }
    },
    "spec": {
      "size": 3,
      "version": "3.2.13"
    }
  },
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdRestore",
    "metadata": {
      "name": "example-etcd-cluster-restore"
    },
    "spec": {
      "etcdCluster": {
        "name": "example-etcd-cluster"
      },
      "backupStorageType": "S3",
      "s3": {
        "path": "<full-s3-path>",
        "awsSecret": "<aws-secret>"
      }
    }
  },
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdBackup",
    "metadata": {
      "name": "example-etcd-cluster-backup"
    },
    "spec": {
      "etcdEndpoints": ["<etcd-cluster-endpoints>"],
      "storageType":"S3",
      "s3": {
        "path": "<full-s3-path>",
        "awsSecret": "<aws-secret>"
      }
    }
  }
]

        Capabilities:           Full Lifecycle
        Categories:             Database
        Container Image:        quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b
        Created At:             2019-02-28 01:03:00
        Description:            Create and maintain highly-available etcd clusters on Kubernetes
        Repository:             https://github.com/coreos/etcd-operator
        Tectonic - Visibility:  ocs
      Apiservicedefinitions:
      Customresourcedefinitions:
        Owned:
          Description:   Represents a cluster of etcd nodes.
          Display Name:  etcd Cluster
          Kind:          EtcdCluster
          Name:          etcdclusters.etcd.database.coreos.com
          Version:       v1beta2
          Description:   Represents the intent to backup an etcd cluster.
          Display Name:  etcd Backup
          Kind:          EtcdBackup
          Name:          etcdbackups.etcd.database.coreos.com
          Version:       v1beta2
          Description:   Represents the intent to restore an etcd cluster from a backup.
          Display Name:  etcd Restore
          Kind:          EtcdRestore
          Name:          etcdrestores.etcd.database.coreos.com
          Version:       v1beta2
      Description:       The etcd Operater creates and maintains highly-available etcd clusters on Kubernetes, allowing engineers to easily deploy and manage etcd clusters for their applications.

etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines. It’s open-source and available on GitHub. etcd gracefully handles leader elections during network partitions and will tolerate machine failure, including the leader.


### Reading and writing to etcd

Communicate with etcd though its command line utility `etcdctl` via port forwarding:

    $ kubectl --namespace default port-forward service/example-client 2379:2379
    $ etcdctl --endpoints http://127.0.0.1:2379 get /

Or directly to the API using the automatically generated Kubernetes Service:

    $ etcdctl --endpoints http://example-client.default.svc:2379 get /

Be sure to secure your etcd cluster (see Common Configurations) before exposing it outside of the namespace or cluster.


### Supported Features

* **High availability** - Multiple instances of etcd are networked together and secured. Individual failures or networking issues are transparently handled to keep your cluster up and running.

* **Automated updates** - Rolling out a new etcd version works like all Kubernetes rolling updates. Simply declare the desired version, and the etcd service starts a safe rolling update to the new version automatically.

* **Backups included** - Create etcd backups and restore them through the etcd Operator.

### Common Configurations

* **Configure TLS** - Specify [static TLS certs](https://github.com/coreos/etcd-operator/blob/master/doc/user/cluster_tls.md) as Kubernetes secrets.

* **Set Node Selector and Affinity** - [Spread your etcd Pods](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#three-member-cluster-with-node-selector-and-anti-affinity-across-nodes) across Nodes and availability zones.

* **Set Resource Limits** - [Set the Kubernetes limit and request](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#three-member-cluster-with-resource-requirement) values for your etcd Pods.

* **Customize Storage** - [Set a custom StorageClass](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#custom-persistentvolumeclaim-definition) that you would like to use.

      Display Name:  etcd
      Install Modes:
        Supported:  true
        Type:       OwnNamespace
        Supported:  false
        Type:       SingleNamespace
        Supported:  false
        Type:       MultiNamespace
        Supported:  true
        Type:       AllNamespaces
      Keywords:
        etcd
        key value
        database
        coreos
        open source
      Links:
        Name:  Blog
        URL:   https://coreos.com/etcd
        Name:  Documentation
        URL:   https://coreos.com/operators/etcd/docs/latest/
        Name:  etcd Operator Source Code
        URL:   https://github.com/coreos/etcd-operator
      Maintainers:
        Email:   etcd-dev@googlegroups.com
        Name:    etcd Community
      Maturity:  alpha
      Provider:
        Name:  CNCF
      Related Images:
        quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b
      Version:  0.9.4-clusterwide
    Entries:
      Name:       etcdoperator.v0.9.4-clusterwide
      Version:    0.9.4-clusterwide
      Name:       etcdoperator.v0.9.2-clusterwide
      Version:    0.9.2-clusterwide
      Name:       etcdoperator.v0.9.0
      Version:    0.9.0
    Name:         clusterwide-alpha
    Current CSV:  etcdoperator.v0.9.4
    Current CSV Desc:
      Annotations:
        Alm - Examples:  [
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdCluster",
    "metadata": {
      "name": "example"
    },
    "spec": {
      "size": 3,
      "version": "3.2.13"
    }
  },
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdRestore",
    "metadata": {
      "name": "example-etcd-cluster-restore"
    },
    "spec": {
      "etcdCluster": {
        "name": "example-etcd-cluster"
      },
      "backupStorageType": "S3",
      "s3": {
        "path": "<full-s3-path>",
        "awsSecret": "<aws-secret>"
      }
    }
  },
  {
    "apiVersion": "etcd.database.coreos.com/v1beta2",
    "kind": "EtcdBackup",
    "metadata": {
      "name": "example-etcd-cluster-backup"
    },
    "spec": {
      "etcdEndpoints": ["<etcd-cluster-endpoints>"],
      "storageType":"S3",
      "s3": {
        "path": "<full-s3-path>",
        "awsSecret": "<aws-secret>"
      }
    }
  }
]

        Capabilities:           Full Lifecycle
        Categories:             Database
        Container Image:        quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b
        Created At:             2019-02-28 01:03:00
        Description:            Create and maintain highly-available etcd clusters on Kubernetes
        Repository:             https://github.com/coreos/etcd-operator
        Tectonic - Visibility:  ocs
      Apiservicedefinitions:
      Customresourcedefinitions:
        Owned:
          Description:   Represents a cluster of etcd nodes.
          Display Name:  etcd Cluster
          Kind:          EtcdCluster
          Name:          etcdclusters.etcd.database.coreos.com
          Version:       v1beta2
          Description:   Represents the intent to backup an etcd cluster.
          Display Name:  etcd Backup
          Kind:          EtcdBackup
          Name:          etcdbackups.etcd.database.coreos.com
          Version:       v1beta2
          Description:   Represents the intent to restore an etcd cluster from a backup.
          Display Name:  etcd Restore
          Kind:          EtcdRestore
          Name:          etcdrestores.etcd.database.coreos.com
          Version:       v1beta2
      Description:       The etcd Operater creates and maintains highly-available etcd clusters on Kubernetes, allowing engineers to easily deploy and manage etcd clusters for their applications.

etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines. It’s open-source and available on GitHub. etcd gracefully handles leader elections during network partitions and will tolerate machine failure, including the leader.


### Reading and writing to etcd

Communicate with etcd though its command line utility `etcdctl` via port forwarding:

    $ kubectl --namespace default port-forward service/example-client 2379:2379
    $ etcdctl --endpoints http://127.0.0.1:2379 get /

Or directly to the API using the automatically generated Kubernetes Service:

    $ etcdctl --endpoints http://example-client.default.svc:2379 get /

Be sure to secure your etcd cluster (see Common Configurations) before exposing it outside of the namespace or cluster.


### Supported Features

* **High availability** - Multiple instances of etcd are networked together and secured. Individual failures or networking issues are transparently handled to keep your cluster up and running.

* **Automated updates** - Rolling out a new etcd version works like all Kubernetes rolling updates. Simply declare the desired version, and the etcd service starts a safe rolling update to the new version automatically.

* **Backups included** - Create etcd backups and restore them through the etcd Operator.

### Common Configurations

* **Configure TLS** - Specify [static TLS certs](https://github.com/coreos/etcd-operator/blob/master/doc/user/cluster_tls.md) as Kubernetes secrets.

* **Set Node Selector and Affinity** - [Spread your etcd Pods](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#three-member-cluster-with-node-selector-and-anti-affinity-across-nodes) across Nodes and availability zones.

* **Set Resource Limits** - [Set the Kubernetes limit and request](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#three-member-cluster-with-resource-requirement) values for your etcd Pods.

* **Customize Storage** - [Set a custom StorageClass](https://github.com/coreos/etcd-operator/blob/master/doc/user/spec_examples.md#custom-persistentvolumeclaim-definition) that you would like to use.

      Display Name:  etcd
      Install Modes:
        Supported:  true
        Type:       OwnNamespace
        Supported:  true
        Type:       SingleNamespace
        Supported:  false
        Type:       MultiNamespace
        Supported:  false
        Type:       AllNamespaces
      Keywords:
        etcd
        key value
        database
        coreos
        open source
      Links:
        Name:  Blog
        URL:   https://coreos.com/etcd
        Name:  Documentation
        URL:   https://coreos.com/operators/etcd/docs/latest/
        Name:  etcd Operator Source Code
        URL:   https://github.com/coreos/etcd-operator
      Maintainers:
        Email:   etcd-dev@googlegroups.com
        Name:    etcd Community
      Maturity:  alpha
      Provider:
        Name:  CNCF
      Related Images:
        quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b
      Version:  0.9.4
    Entries:
      Name:         etcdoperator.v0.9.4
      Version:      0.9.4
      Name:         etcdoperator.v0.9.2
      Version:      0.9.2
      Name:         etcdoperator.v0.9.0
      Version:      0.9.0
    Name:           singlenamespace-alpha
  Default Channel:  singlenamespace-alpha
  Package Name:     etcd
  Provider:
    Name:  CNCF
Events:    <none>

OperatorGroup 对象定义的Operator组,选择目标namespace,在其中为同一namespace中的所有Operator生成所需的RBAC访问权限。

订阅Operator的namespace必须具有与Operator的安装模式( AllNamespacesSingleNamespace 模式)相匹配的Operator组。如果要使用 AllNamespaces 安装Operator,则 openshift-operators namespace已有适当的Operator组。

不过,如果采用 SingleNamespace 模式,而还没有适当的Operator组,则必须创建一个。

注意:前面在使用web console时,选择 SingleNamespace 模式,则在后台自动创建了 OperatorGroupSubscription 对象。

创建 OperatorGroup 对象YAML文件,比如 operatorgroup.yaml

apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: <operatorgroup_name>
  namespace: <namespace>
spec:
  targetNamespaces:
  - <namespace>
  • <operatorgroup_name>my-operatorgroup
  • <namespace>my-etcd

注意:OLM为每个Operator组创建以下集群角色:

  • <operatorgroup_name>-admin
  • <operatorgroup_name>-edit
  • <operatorgroup_name>-view

当手动创建Operator组时,必须指定一个唯一名称,该名称不能和现有集群角色或其它Operator组冲突。

创建 OperatorGroup 对象:

oc apply -f operatorgroup.yaml

创建一个 Subscription 对象YAML文件,为Operator订阅一个namespace,比如 sub.yaml

apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: <subscription_name>
  # namespace: openshift-operators # 1
  namespace: my-etcd # 1
spec:
  channel: <channel_name> # 2
  name: <operator_name> # 3
  source: redhat-operators # 4
  sourceNamespace: openshift-marketplace # 5
  config:
    env: # 6
    - name: ARGS
      value: "-v=10"
    envFrom: # 7
    - secretRef:
        name: license-secret
    volumes: # 8
    - name: <volume_name>
      configMap:
        name: <configmap_name>
    volumeMounts: # 9
    - mountPath: <directory_name>
      name: <volume_name>
    tolerations: # 10
    - operator: "Exists"
    resources: # 11
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
    nodeSelector: # 12
      foo: bar
  1. 对于默认的 AllNamespaces 安装模式用法,需指定 openshift-operators namespace。也可以指定一个自定义的全局namespace(如果创建了)。否则,需为 SingleNamespace 安装模式使用指定关联的单个namespace。

本例中,指定了 my-etcd namespace。

  • <subscription_name>etcd
  • <channel_name>singlenamespace-alpha
  • <operator_name>etcd
  • <volume_name>my-volume
  • <configmap_name>my-configmap
  • <directory_name>my-directory

如果集群为STS模式,在 Subscription 对象中包含以下字段:

kind: Subscription
# ...
spec:
  installPlanApproval: Manual # 1
  config:
    env:
    - name: ROLEARN
      value: "<role_arn>" # 2

创建 Subscription 对象:

oc apply -f sub.yaml

此时,OLM已能感知到所选的Operator。Operator的CSV应该已经出现在目标namespace中,由Operator所提供的API应该已经可用于创建。

注:文档说的不是很清楚,本例应该用不到ConfigMap、PVC、PV,这可能只是一个模板。我没有实际实验。

从已安装的Operator创建应用

使用Operator创建etcd集群

前面安装好etcd Operator后,在web console上点击etcd,查看详情。

Provided APIs 下,可见该Operator提供了三类新资源:

  • etcd Cluster
  • etcd Backup
  • etcd Restore

这些对象的工作方式与内建的原生Kubernetes对象(比如 DeploymentReplicaSet )相似,但包含管理etcd所特有的逻辑。

在这里插入图片描述

点击“etcd Cluster”下方的“Create instance”,如下:

在这里插入图片描述

点击左下角“Create”按钮,如下:

在这里插入图片描述

报错

点击“EC example”(EC表示EtcdCluster),然后查看Resources页签:

在这里插入图片描述
可以看到pod处于pending状态。

(注:上图是一个clusterwide的Operator,因为我重新安装过Operater,不过问题都是一样的。)

从web console debug

点击“example-bcqztbd6l6”pod,然后查看“Logs”页签:

在这里插入图片描述

可以看到,“etcd”容器没有任何log(因为它处于“waiting”状态)。切换到“check-dns”容器,可以看到其log:

在这里插入图片描述

可以看到,在不断的产生重复的log:

......
nslookup: can't resolve 'example-bcqztbd6l6.example.my-etcd.svc'
Server: 10.217.4.10
Address 1: 10.217.4.10 dns-default.openshift-dns.svc.cluster.local
......

从命令行debug

在命令行查看pod:

$ oc describe pod example-bcqztbd6l6 -n my-etcd
Name:             example-bcqztbd6l6
Namespace:        my-etcd
......
Init Containers:
  check-dns:
    Container ID:  cri-o://8e4f03cfea06f682d877e6122ebd84f4b6f8ae75f87ba0fd3ebae1fabd36ebbe
    Image:         busybox:1.28.0-glibc
    Image ID:      docker.io/library/busybox@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6
    Port:          <none>
    Host Port:     <none>
    Command:
      /bin/sh
      -c
      
                TIMEOUT_READY=0
                while ( ! nslookup example-bcqztbd6l6.example.my-etcd.svc )
                do
                  # If TIMEOUT_READY is 0 we should never time out and exit 
                  TIMEOUT_READY=$(( TIMEOUT_READY-1 ))
                              if [ $TIMEOUT_READY -eq 0 ];
                                  then
                                      echo "Timed out waiting for DNS entry"
                                      exit 1
                                  fi
                              sleep 1
                            done
    State:          Running
      Started:      Wed, 14 Feb 2024 17:49:40 +0800
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:         <none>
Containers:
  etcd:
    Container ID:  
    Image:         quay.io/coreos/etcd:v3.2.13
    Image ID:      
    Ports:         2380/TCP, 2379/TCP
    Host Ports:    0/TCP, 0/TCP
    Command:
      /usr/local/bin/etcd
      --data-dir=/var/etcd/data
      --name=example-bcqztbd6l6
      --initial-advertise-peer-urls=http://example-bcqztbd6l6.example.my-etcd.svc:2380
      --listen-peer-urls=http://0.0.0.0:2380
      --listen-client-urls=http://0.0.0.0:2379
      --advertise-client-urls=http://example-bcqztbd6l6.example.my-etcd.svc:2379
      --initial-cluster=example-bcqztbd6l6=http://example-bcqztbd6l6.example.my-etcd.svc:2380
      --initial-cluster-state=new
      --initial-cluster-token=a8f3fa08-f114-4c12-95b7-60e14eea400c
    State:          Waiting
      Reason:       PodInitializing
    Ready:          False
    Restart Count:  0
    Liveness:       exec [/bin/sh -ec ETCDCTL_API=3 etcdctl endpoint status] delay=10s timeout=10s period=60s #success=1 #failure=3
    Readiness:      exec [/bin/sh -ec ETCDCTL_API=3 etcdctl endpoint status] delay=1s timeout=5s period=5s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /var/etcd from etcd-data (rw)
Conditions:
  Type              Status
  Initialized       False 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
......

可见,在 Init Containers: 处,其 Command 是一段脚本,包含了一个死循环,只要 nslookup example-bcqztbd6l6.example.my-etcd.svc 有问题(返回值不为0),就会一直循环下去。

在命令行查看log:

$ oc logs example-bcqztbd6l6 -n my-etcd
Defaulted container "etcd" out of: etcd, check-dns (init)
Error from server (BadRequest): container "etcd" in pod "example-bcqztbd6l6" is waiting to start: PodInitializing

说明pod里的 etcd 容器在等待pod初始化。

查看 etcd 容器的log:

$ oc logs example-bcqztbd6l6 -c etcd -n my-etcd
Error from server (BadRequest): container "etcd" in pod "example-bcqztbd6l6" is waiting to start: PodInitializing

只是说在等待pod初始化。从以上log看不出来pod卡在那里了,只能通过 describe pod 看到有段 Init Containers 逻辑,得知 check-dns 容器,然后查看其log:

$ oc logs example-bcqztbd6l6 -c check-dns -n my-etcd
......
nslookup: can't resolve 'example-bcqztbd6l6.example.my-etcd.svc'
Server:    10.217.4.10
Address 1: 10.217.4.10 dns-default.openshift-dns.svc.cluster.local
......

可见,和从web console看到的log是一致的。

分析

为什么会报这个错误呢?我在网上百度了一下,貌似这是 busybox 的一个bug。

参见 https://stackoverflow.com/questions/52109039/nslookup-cant-resolve-kubernetes-default ,里面提到:

You have encountered a bug in the latest versions of the busybox docker image. Use the tag busybox:1.28 instead of latest.

原issue: https://github.com/docker-library/busybox/issues/48

不过也可能是因为我使用的是Red Hat OpenShift Local。没有深究。

参考

  • https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/operators/index#user-tasks

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1452175.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

机器学习面试:请你谈谈生成模型和判别模型的区别?

生成模型:由数据学习联合概率密度分布P(XY)&#xff0c;然后求出条件概率分布P(YIX)作为预测的模型&#xff0c;即生成模型:P(Y|X) P(X,Y)/ P(X)(贝叶斯概率)。基本思想是首先建立样本的联合概率概率密度模型P(X,Y)然后再得到后验概率P(Y|X)&#xff0c;再利用它进行分类。典型…

数学实验第三版(主编:李继成 赵小艳)课后练习答案(十二)(4)

实验十二&#xff1a;微分方程模型 练习四 1.如图12.12所示,有一只猎狗在B点位置发现了一只兔子在正东北方距离它200m的地方0处,此时兔子开始以8m/s的速度向正西北方距离为120m的洞口A全速跑去,假设猎狗在追赶兔子的时候始终朝着兔子的方向全速奔跑,按要求完成下面的实验: (1…

BulingBuling - 《自律就是自由》 [ Discipline Equals Freedom ]

自律就是自由 实战手册 作者&#xff1a;Jocko Willink Discipline Equals Freedom Field Manual By Jocko Willink 简介 《自律就是自由》&#xff08;2020年&#xff09;是一本关于自律艺术的实战手册。它揭示了你需要做什么来满足你的全部潜能--以及为什么自律能让你自…

【HarmonyOS】hdc 环境变量设置

hdc&#xff08;HarmonyOS Device Connector&#xff09;是 HarmonyOS 为开发人员提供的用于调试的命令行工具&#xff0c;通过该工具可以在 windows/linux/mac 系统上与真实设备或者模拟器进行交互。 hdc 工具通过 HarmonyOS SDK 获取&#xff0c;存放于 /Huawei/Sdk/openhar…

英文论文(sci)解读复现【NO.18】基于DS-YOLOv8的目标检测方法用于遥感图像

此前出了目标检测算法改进专栏&#xff0c;但是对于应用于什么场景&#xff0c;需要什么改进方法对应与自己的应用场景有效果&#xff0c;并且多少改进点能发什么水平的文章&#xff0c;为解决大家的困惑&#xff0c;此系列文章旨在给大家解读发表高水平学术期刊中的 SCI论文&a…

机器学习:k近邻算法(Python)

一、k近邻算法的定义 二、KD树结点信息封装 kdtree_node.py class KDTreeNode:"""KD树结点信息封装"""def __init__(self, instance_nodeNone, instance_labelNone, instance_idxNone,split_featureNone, left_childNone, right_childNone, kd…

对待不合理需求,前端工程师如何优雅的say no!

曾经有位老板&#xff0c; 每次给前端提需求&#xff0c;前端都说实现不了&#xff0c;后来他搜索了一下&#xff0c;发现网上都有答案。他就在招聘要求上加了条&#xff1a;麻烦你在说不行的时候&#xff0c;搜索一下。 上面是一个段子&#xff0c;说的有点极端了&#xff0c;…

简单DP算法(动态规划)

简单DP算法 算法思想例题1、01背包问题题目信息思路题解 2、摘花生题目信息思路题解 3、最长上升子序列题目信息思路题解 题目练习1、地宫取宝题目信息思路题解 2、波动数列题目信息思路题解 算法思想 从集合角度来分析DP问题 例如求最值、求个数 例题 1、01背包问题 题目…

2.16学习总结

1.邮递员送信&#xff08;dijkstra 不只是从起到到目标点&#xff0c;还要走回去&#xff09; 2.炸铁路(并查集) 3.统计方形&#xff08;数据加强版&#xff09;&#xff08;排列组合&#xff09; 4.滑雪&#xff08;记忆化&#xff09; 5.小车问题&#xff08;数学问题&#x…

高B格可视化大屏设计具备的10大特征

简洁明了&#xff1a; 可视化大屏界面应该尽可能简洁明了&#xff0c;突出重点&#xff0c;避免过多的信息和视觉干扰。同时&#xff0c;需要考虑到用户的视觉效果和易用性&#xff0c;使用户能够迅速地获取所需信息。 数据精准&#xff1a; 可视化大屏界面显示的数据应该准确…

阿里云BGP多线精品EIP香港CN2线路低时延,价格贵

阿里云香港等地域服务器的网络线路类型可以选择BGP&#xff08;多线&#xff09;和 BGP&#xff08;多线&#xff09;精品&#xff0c;普通的BGP多线和精品有什么区别&#xff1f;BGP&#xff08;多线&#xff09;适用于香港本地、香港和海外之间的互联网访问。使用BGP&#xf…

react+ts【项目实战一】配置项目/路由/redux

文章目录 1、项目搭建1、创建项目1.2 配置项目1.2.1 更换icon1.2.2 更换项目名称1.2.1 配置项目别名 1.3 代码规范1.3.1 集成editorconfig配置1.3.2 使用prettier工具 1.4 项目结构1.5 对css进行重置1.6 注入router1.7 定义TS组件的规范1.8 创建代码片段1.9 二级路由和懒加载1.…

今日早报 每日精选15条新闻简报 每天一分钟 知晓天下事 2月17日,星期六

每天一分钟&#xff0c;知晓天下事&#xff01; 2024年2月17日 星期六 农历正月初八 1、 中疾控&#xff1a;我国自主研发的猴痘mRNA疫苗即将进入临床试验。 2、 2024年度总票房破100亿元&#xff0c;其中春节档已突破70亿元。 3、 国产大飞机首次国外亮相&#xff0c;C919已抵…

5年前端老司机:浅谈web前端开发技术点

有部分同学和朋友问到过我相关问题。利用周末我就浅浅地谈谈我对web前端开发的理解和体会&#xff0c;仅仅能浅浅谈谈&#xff0c;高手请自己主动跳过本篇文章。 毕竟我如今经验并非非常足&#xff0c;连project师都算不上&#xff0c;更不用说大牛了。今天也不谈技术。技术非…

2.14日学习打卡----初学Zookeeper(一)

2.14日学习打卡 目录: 2.14日学习打卡Zookeeper概念一. 集中式到分布式单机架构集群架构什么是分布式三者区别 二. CAP定理分区容错性一致性可用性一致性和可用性的矛盾一致性和可用性如何选择 三. 什么是Zookeeper分布式架构Zookeeper从何而来Zookeeper介绍 四. 应用场景数据发…

Android 车载应用开发之SystemUI 详解

一、SystemUI SystemUI全称System User Interface,直译过来就是系统级用户交互界面,在 Android 系统中由SystemUI负责统一管理整个系统层的 UI,它是一个系统级应用程序(APK),源码在/frameworks/base/packages/目录下,而不是在/packages/目录下,这也说明了SystemUI这个…

集群聊天项目

不懂的一些东西 (const TcpConnectionPtr&&#xff09;作为形参啥意思&#xff1a;接收一个常量引用&#xff0c;函数内部不允许修改该指针所指向的对象。 优势 1.网络层与业务层分离&#xff1a;通过网络层传来的id&#xff0c;设计一个map存储id以及对印的业务处理器&…

文件上传漏洞--Upload-labs--Pass01--前端绕过

一、前端绕过原理 通俗解释&#xff0c;我们将写有恶意代码的php后缀文件上传到网页&#xff0c;网页中的javascript代码会先对文件的后缀名进行检测&#xff0c;若检测到上传文件的后缀名为非法&#xff0c;则会进行alert警告。若想上传php后缀的文件&#xff0c;就要想办法对…

windows一开机一直循环:No Boot Device Found. Press any key to reboot the machine解决方法

一、长按F12 二、选择Settiings/General/Boot Sequence 三、选择UEFI模式&#xff0c; 四、选择下方APPLY 五、退出&#xff1a;

【Spring面试题】

目录 前言 1.Spring框架中的单例bean是线程安全的吗? 2.什么是AOP? 3.你们项目中有没有使用到AOP&#xff1f; 4.Spring中的事务是如何实现的&#xff1f; 5.Spring中事务失效的场景有哪些&#xff1f; 6.Spring的bean的生命周期。 7.Spring中的循环引用 8.构造方法…