OpenShift: クラスターネットワーク情報の確認方法

いつも忘れてしまうので、備忘録も兼ねて記載。
今回はRed Hat OpenShift on IBM Cloud(VPC)を利用

# Cluster Network

（参考情報）
https://access.redhat.com/documentation/ja-jp/openshift_container_platform/4.4/html/networking/nw-cno-view_cluster-network-operator

以下の結果から、

- Pod Network: 172.21.0.0/16
- Host Prefixが23。よって $ 2^{(32-23)}$=512 までがサポートされるノード数であり、実際に[IBM Cloud docs](https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_limitations)に記載されている、「Worker nodeが500台まで」という情報に一致する。
- Cluster Network(Pod Network): 172.17.64.0/18
- CNI: Calico

などがわかる。

```
$ oc describe network.config/cluster
Name:         cluster
Namespace:
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"config.openshift.io/v1","kind":"Network","metadata":{"annotations":{},"creationTimestamp":null,"name":"cluster"},"spec":{"c...
API Version:  config.openshift.io/v1
Kind:         Network
Metadata:
  Creation Timestamp:  2020-07-01T05:33:07Z
  Generation:          2
  Resource Version:    6239
  Self Link:           /apis/config.openshift.io/v1/networks/cluster
  UID:                 4b25e676-324c-4105-b98c-31a10b757788
Spec:
  Cluster Network:
    Cidr:         172.17.64.0/18
    Host Prefix:  23
  External IP:
    Policy:
  Network Type:  Calico
  Service Network:
    172.21.0.0/16
Status:
  Cluster Network:
    Cidr:               172.17.64.0/18
    Host Prefix:        23
  Cluster Network MTU:  1480
  Network Type:         Calico
  Service Network:
    172.21.0.0/16
Events:  <none>
```


```shell-session:PodとServiceのネットワークアドレス例
$ oc get pods,services -o wide
NAME                       READY   STATUS      RESTARTS   AGE     IP               NODE           NOMINATED NODE   READINESS GATES
pod/hello-world-1-45m9j    1/1     Running     0          5d14h   172.17.111.9     10.240.128.4   <none>           <none>
pod/hello-world-1-b75zr    1/1     Running     0          5d14h   172.17.115.137   10.240.128.5   <none>           <none>
pod/hello-world-1-build    0/1     Completed   0          5d14h   172.17.115.136   10.240.128.5   <none>           <none>
pod/hello-world-1-deploy   0/1     Completed   0          5d14h   172.17.123.75    10.240.0.4     <none>           <none>
pod/hello-world-1-gl5sd    1/1     Running     0          5d14h   172.17.74.18     10.240.64.5    <none>           <none>
pod/hello-world-1-j8w4f    1/1     Running     0          5d14h   172.17.67.14     10.240.64.4    <none>           <none>
pod/hello-world-1-rb8nt    1/1     Running     0          5d14h   172.17.123.76    10.240.0.4     <none>           <none>

NAME                      TYPE           CLUSTER-IP      EXTERNAL-IP                            PORT(S)          AGE     SELECTOR
service/hello-world       ClusterIP      172.21.14.37    <none>                                 8080/TCP         5d14h   deploymentconfig=hello-world
service/hello-world-lb    LoadBalancer   172.21.82.182   xxxxxxxx-us-south.lb.appdomain.cloud   80:32737/TCP     4d2h    deploymentconfig=hello-world
service/hello-world-lb2   LoadBalancer   172.21.93.55    yyyyyyyy-us-south.lb.appdomain.cloud   8080:32532/TCP   4d1h    deploymentconfig=hello-world
```

# DNS

（参考情報）
https://access.redhat.com/documentation/ja-jp/openshift_container_platform/4.4/html/networking/nw-dns-view_dns-operator
https://access.redhat.com/documentation/ja-jp/openshift_container_platform/4.4/html/networking/nw-dns-forward_dns-operator

以下の結果から、

Cluster Domain: cluster.local
内部DNS: 172.21.0.10

などがわかる。

```
$ oc describe dns.operator/default
Name:         default
Namespace:
Labels:       <none>
Annotations:  <none>
API Version:  operator.openshift.io/v1
Kind:         DNS
Metadata:
  Creation Timestamp:  2020-07-01T05:50:15Z
  Finalizers:
    dns.operator.openshift.io/dns-controller
  Generation:        1
  Resource Version:  14196
  Self Link:         /apis/operator.openshift.io/v1/dnses/default
  UID:               dc453161-77dc-48c2-82a0-010a15404ede
Spec:
Status:
  Cluster Domain:  cluster.local
  Cluster IP:      172.21.0.10
  Conditions:
    Last Transition Time:  2020-07-01T05:51:50Z
    Message:               ClusterIP assigned to DNS Service and minimum DaemonSet pods running
    Reason:                AsExpected
    Status:                False
    Type:                  Degraded
    Last Transition Time:  2020-07-01T05:54:25Z
    Message:               All expected Nodes running DaemonSet pod
    Reason:                AsExpected
    Status:                False
    Type:                  Progressing
    Last Transition Time:  2020-07-01T05:50:42Z
    Message:               Minimum number of Nodes running DaemonSet pod
    Reason:                AsExpected
    Status:                True
    Type:                  Available
Events:                    <none>
```

```txt:DNS情報確認例
$ oc rsh pod/hello-world-1-45m9j cat /etc/resolv.conf
search syasuda.svc.cluster.local svc.cluster.local cluster.local
nameserver 172.21.0.10
options ndots:5
```