2/2 在 kubectl get all -n cass-operator 的输出中意味着什么
What does 2/2 mean in output of kubectl get all -n cass-operator
我有一个 3 节点 Kubernetes 集群,我已经使用 Cass-Operator 在其上设置了 Cassandra。我正在按照此处的说明进行操作 - https://github.com/datastax/cass-operator
以下命令输出中的 2/2 是什么意思
kubectl get all -n cass-operator
NAME READY STATUS RESTARTS AGE
pod/cass-operator-78c6469c6-6qhsb 1/1 Running 0 139m
pod/cluster1-dc1-default-sts-0 2/2 Running 0 138m
pod/cluster1-dc1-default-sts-1 2/2 Running 0 138m
pod/cluster1-dc1-default-sts-2 2/2 Running 0 138m
是否意味着有3个数据中心每个运行 2个cassandra节点?应该是因为我的K8S集群只有3个节点。
manuchadha25@cloudshell:~ (copper-frame-262317)$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-cassandra-cluster-default-pool-92d544da-6fq8 europe-west4-a n1-standard-1 10.164.0.26 34.91.214.233 RUNNING
gke-cassandra-cluster-default-pool-92d544da-g0b5 europe-west4-a n1-standard-1 10.164.0.25 34.91.101.218 RUNNING
gke-cassandra-cluster-default-pool-92d544da-l87v europe-west4-a n1-standard-1 10.164.0.27 34.91.86.10 RUNNING
或者 Cassandra-operator 运行 每个 K8S 节点两个容器?
当您部署一些应用程序时,一个 pod 中可以有多个容器。如果您检查 Kubernetes Pod docs,您会发现 2 个类型:
Pods即运行单个容器。
The "one-container-per-Pod" model is the most common Kubernetes use case; in this case, you can think of a Pod as a wrapper around a single container, and Kubernetes manages the Pods rather than the containers directly.
Pods 即运行 需要协同工作的多个容器。
A Pod might encapsulate an application composed of multiple co-located containers that are tightly coupled and need to share resources. These co-located containers might form a single cohesive unit of service--one container serving files from a shared volume to the public, while a separate "sidecar" container refreshes or updates those files. The Pod wraps these containers and storage resources together as a single manageable entity.
您可以在 this docs 中找到更多信息。
可以找到 Pod
如何使用 2 个容器配置 YAML here。在 .spec.containers
中,您可以指定 2 个或更多容器。
我已经部署了那些 YAML。
$ kubectl get po -n cass-operator
NAME READY STATUS RESTARTS AGE
cass-operator-78c9999797-gb88g 1/1 Running 0 4m26s
cluster1-dc1-default-sts-0 2/2 Running 0 4m12s
cluster1-dc1-default-sts-1 2/2 Running 0 4m12s
cluster1-dc1-default-sts-2 2/2 Running 0 4m12s
现在您必须描述 pod。在我的示例中:
$ kubectl describe po cluster1-dc1-default-sts-0 -n cass-operator
在 Containers:
下,您可以找到图像、端口、状态、安装等详细信息。
Containers:
cassandra:
Container ID: docker://49b58eacc380da6c29928677e84082373d4330a91c29b29f3f3b021e43c21a38
Image: datastax/cassandra-mgmtapi-3_11_6:v0.1.5
Image ID: docker-pullable://datastax/cassandra-mgmtapi-3_11_6@sha256:aa7d6072607e60b1dfddd5877dcdf436660bacd31dd4aa6c8c2b85978c9fd170
....
server-system-logger:
Container ID: docker://d0b572e767236e2baab7b67d5ad0fc6656b862fc4e463aa1836de80d34f608ea
Image: busybox
Image ID: docker-pullable://busybox@sha256:2131f09e4044327fd101ca1fd4043e6f3ad921ae7ee901e9142e6e36b354a907
Port: <none>
所以这个 pod 运行s 2 个容器
- 姓名:
cassandra
- 姓名:
server-system-logger
有1/2
的pod怎么办?
表示在这个特定的pod
中只有1个容器是running
。容器状态为 Waiting
、Running
和 Terminated
。您可以找到更多信息 here.
用例?
您可以查看指定容器的日志。
$ kubectl logs cluster1-dc1-default-sts-0 -n cass-operator -c cassandra
Starting Management API
/docker-entrypoint.sh: line 74: [: missing `]'
Running java -Xms128m -Xmx128m -jar /opt/mgmtapi/datastax-mgmtapi-server-0.1.0-SNAPSHOT.jar --cassandra-socket /tmp/cassandra.sock --host tcp://0.0.0.0:8080 --host file:///tmp/oss-mgmt.sock --explicit-start true --cassandra-home /var/lib/cassandra/
INFO [main] 2020-07-03 13:43:08,199 Cli.java:343 - Cassandra Version 3.11.6
INFO [main] 2020-07-03 13:43:08,709 ResteasyDeploymentImpl.java:551 - RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.datastax.mgmtapi.ManagementApplication
...
或
$ kubectl logs cluster1-dc1-default-sts-0 -n cass-operator -c server-system-logger
INFO [main] 2020-07-03 13:44:04,588 YamlConfigurationLoader.java:89 - Configuration location: file:/etc/cassandra/cassandra.yaml
INFO [main] 2020-07-03 13:44:06,137 Config.java:516 - Node configuration:[allocate_tokens_for_keyspace=null; authenticator=org.apache.cassandra.auth.PasswordAuthenticator; authorizer=org.apache.cassandra.auth.CassandraAuthorizer; auto_bootstrap=true; auto_snapshot=true;
...
你也可以获取这个pod YAML来验证。您可以在本示例中通过以下方式完成此操作:
$ kubectl get po cluster1-dc1-default-sts-0 -n cass-operator -o yaml
作为您问题的补充:
或者 Cassandra-operator 运行每个 K8S 节点有两个容器?
运行每个 pod 有两个容器。您可以通过以下方式检查哪个 pod 被调度到哪个节点:
$ kubectl get pods -n cass-operator -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
cass-operator-78c9999797-gb88g 1/1 Running 0 20m 10.44.1.4 gke-cluster-2-default-pool-5aa60336-n3hr <none> <none>
cluster1-dc1-default-sts-0 2/2 Running 0 19m 10.44.1.5 gke-cluster-2-default-pool-5aa60336-n3hr <none> <none>
cluster1-dc1-default-sts-1 2/2 Running 0 19m 10.44.2.3 gke-cluster-2-default-pool-5aa60336-dl2g <none> <none>
cluster1-dc1-default-sts-2 2/2 Running 0 19m 10.44.0.9 gke-cluster-2-default-pool-5aa60336-m7ms <none> <none>
我有一个 3 节点 Kubernetes 集群,我已经使用 Cass-Operator 在其上设置了 Cassandra。我正在按照此处的说明进行操作 - https://github.com/datastax/cass-operator
以下命令输出中的 2/2 是什么意思
kubectl get all -n cass-operator
NAME READY STATUS RESTARTS AGE
pod/cass-operator-78c6469c6-6qhsb 1/1 Running 0 139m
pod/cluster1-dc1-default-sts-0 2/2 Running 0 138m
pod/cluster1-dc1-default-sts-1 2/2 Running 0 138m
pod/cluster1-dc1-default-sts-2 2/2 Running 0 138m
是否意味着有3个数据中心每个运行 2个cassandra节点?应该是因为我的K8S集群只有3个节点。
manuchadha25@cloudshell:~ (copper-frame-262317)$ gcloud compute instances list
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
gke-cassandra-cluster-default-pool-92d544da-6fq8 europe-west4-a n1-standard-1 10.164.0.26 34.91.214.233 RUNNING
gke-cassandra-cluster-default-pool-92d544da-g0b5 europe-west4-a n1-standard-1 10.164.0.25 34.91.101.218 RUNNING
gke-cassandra-cluster-default-pool-92d544da-l87v europe-west4-a n1-standard-1 10.164.0.27 34.91.86.10 RUNNING
或者 Cassandra-operator 运行 每个 K8S 节点两个容器?
当您部署一些应用程序时,一个 pod 中可以有多个容器。如果您检查 Kubernetes Pod docs,您会发现 2 个类型:
Pods即运行单个容器。
The "one-container-per-Pod" model is the most common Kubernetes use case; in this case, you can think of a Pod as a wrapper around a single container, and Kubernetes manages the Pods rather than the containers directly.
Pods 即运行 需要协同工作的多个容器。
A Pod might encapsulate an application composed of multiple co-located containers that are tightly coupled and need to share resources. These co-located containers might form a single cohesive unit of service--one container serving files from a shared volume to the public, while a separate "sidecar" container refreshes or updates those files. The Pod wraps these containers and storage resources together as a single manageable entity.
您可以在 this docs 中找到更多信息。
可以找到 Pod
如何使用 2 个容器配置 YAML here。在 .spec.containers
中,您可以指定 2 个或更多容器。
我已经部署了那些 YAML。
$ kubectl get po -n cass-operator
NAME READY STATUS RESTARTS AGE
cass-operator-78c9999797-gb88g 1/1 Running 0 4m26s
cluster1-dc1-default-sts-0 2/2 Running 0 4m12s
cluster1-dc1-default-sts-1 2/2 Running 0 4m12s
cluster1-dc1-default-sts-2 2/2 Running 0 4m12s
现在您必须描述 pod。在我的示例中:
$ kubectl describe po cluster1-dc1-default-sts-0 -n cass-operator
在 Containers:
下,您可以找到图像、端口、状态、安装等详细信息。
Containers:
cassandra:
Container ID: docker://49b58eacc380da6c29928677e84082373d4330a91c29b29f3f3b021e43c21a38
Image: datastax/cassandra-mgmtapi-3_11_6:v0.1.5
Image ID: docker-pullable://datastax/cassandra-mgmtapi-3_11_6@sha256:aa7d6072607e60b1dfddd5877dcdf436660bacd31dd4aa6c8c2b85978c9fd170
....
server-system-logger:
Container ID: docker://d0b572e767236e2baab7b67d5ad0fc6656b862fc4e463aa1836de80d34f608ea
Image: busybox
Image ID: docker-pullable://busybox@sha256:2131f09e4044327fd101ca1fd4043e6f3ad921ae7ee901e9142e6e36b354a907
Port: <none>
所以这个 pod 运行s 2 个容器
- 姓名:
cassandra
- 姓名:
server-system-logger
有1/2
的pod怎么办?
表示在这个特定的pod
中只有1个容器是running
。容器状态为 Waiting
、Running
和 Terminated
。您可以找到更多信息 here.
用例? 您可以查看指定容器的日志。
$ kubectl logs cluster1-dc1-default-sts-0 -n cass-operator -c cassandra
Starting Management API
/docker-entrypoint.sh: line 74: [: missing `]'
Running java -Xms128m -Xmx128m -jar /opt/mgmtapi/datastax-mgmtapi-server-0.1.0-SNAPSHOT.jar --cassandra-socket /tmp/cassandra.sock --host tcp://0.0.0.0:8080 --host file:///tmp/oss-mgmt.sock --explicit-start true --cassandra-home /var/lib/cassandra/
INFO [main] 2020-07-03 13:43:08,199 Cli.java:343 - Cassandra Version 3.11.6
INFO [main] 2020-07-03 13:43:08,709 ResteasyDeploymentImpl.java:551 - RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.datastax.mgmtapi.ManagementApplication
...
或
$ kubectl logs cluster1-dc1-default-sts-0 -n cass-operator -c server-system-logger
INFO [main] 2020-07-03 13:44:04,588 YamlConfigurationLoader.java:89 - Configuration location: file:/etc/cassandra/cassandra.yaml
INFO [main] 2020-07-03 13:44:06,137 Config.java:516 - Node configuration:[allocate_tokens_for_keyspace=null; authenticator=org.apache.cassandra.auth.PasswordAuthenticator; authorizer=org.apache.cassandra.auth.CassandraAuthorizer; auto_bootstrap=true; auto_snapshot=true;
...
你也可以获取这个pod YAML来验证。您可以在本示例中通过以下方式完成此操作:
$ kubectl get po cluster1-dc1-default-sts-0 -n cass-operator -o yaml
作为您问题的补充:
或者 Cassandra-operator 运行每个 K8S 节点有两个容器?
运行每个 pod 有两个容器。您可以通过以下方式检查哪个 pod 被调度到哪个节点:
$ kubectl get pods -n cass-operator -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
cass-operator-78c9999797-gb88g 1/1 Running 0 20m 10.44.1.4 gke-cluster-2-default-pool-5aa60336-n3hr <none> <none>
cluster1-dc1-default-sts-0 2/2 Running 0 19m 10.44.1.5 gke-cluster-2-default-pool-5aa60336-n3hr <none> <none>
cluster1-dc1-default-sts-1 2/2 Running 0 19m 10.44.2.3 gke-cluster-2-default-pool-5aa60336-dl2g <none> <none>
cluster1-dc1-default-sts-2 2/2 Running 0 19m 10.44.0.9 gke-cluster-2-default-pool-5aa60336-m7ms <none> <none>