設定kubectl指令

K8S APIS

Cluster info可以知道K8S環境上的一些資訊

$ kubectl cluster-info
Kubernetes master is running at https://104.155.231.49
GLBCDefaultBackend is running at https://104.155.231.49/api/v1/proxy/namespaces/kube-system/services/default-http-backend
Heapster is running at https://104.155.231.49/api/v1/proxy/namespaces/kube-system/services/heapster
KubeDNS is running at https://104.155.231.49/api/v1/proxy/namespaces/kube-system/services/kube-dns
KubeUI is running at https://104.155.231.49/api/v1/proxy/namespaces/kube-system/services/kube-ui

如果想要使用上述的API與Web Console,可以使用下面指令,取出環境的存取帳號密碼:

$ gcloud container clusters describe mygke
clusterIpv4Cidr: 10.172.0.0/14
createTime: '2015-12-20T16:01:52+00:00'
currentMasterVersion: 1.1.3
currentNodeCount: 1
currentNodeVersion: 1.1.3
endpoint: 104.155.231.49
initialClusterVersion: 1.1.3
initialNodeCount: 3
instanceGroupUrls:
- https://www.googleapis.com/replicapool/v1beta2/projects/itri-smart-home/zones/asia-east1-a/instanceGroupManagers/gke-mygke-76b971b7-group
loggingService: logging.googleapis.com
masterAuth:
  clientCertificate: LS0tLS1CRUdJTiBDR...5EIENFUlRJRklDQVRFLS0tLS0K
  clientKey: LS0tLS1CRUdJT...RCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
  clusterCaCertificate: LS0tLS1C...b0JxSktCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
  password: yFE...hAC
  username: admin
monitoringService: monitoring.googleapis.com
name: mygke
network: default
nodeConfig:
  diskSizeGb: 100
  machineType: n1-standard-1
  oauthScopes:
  - https://www.googleapis.com/auth/compute
  - https://www.googleapis.com/auth/devstorage.read_only
  - https://www.googleapis.com/auth/logging.write
  - https://www.googleapis.com/auth/monitoring
nodeIpv4CidrSize: 24
selfLink: https://container.googleapis.com/v1/projects/itri-smart-home/zones/asia-east1-a/clusters/mygke
servicesIpv4Cidr: 10.175.240.0/20
status: RUNNING
zone: asia-east1-a

Request example:

$ curl -k -u admin:yFEvP...WhAC https://104.155.231.49/api/v1/nodes

Result:

{
  "kind": "NodeList",
  "apiVersion": "v1",
  "metadata": {
    "selfLink": "/api/v1/nodes",
    "resourceVersion": "53696"
  },
  "items": [
    {
      "metadata": {
        "name": "gke-mygke-76b971b7-node-r1ph",
        "selfLink": "/api/v1/nodes/gke-mygke-76b971b7-node-r1ph",
        "uid": "5b740b74...2010af000f9",
        "resourceVersion": "53695",
        "creationTimestamp": "2015-12-24T10:44:49Z",
        "labels": {
          "kubernetes.io/hostname": "gke-mygke-76b971b7-node-r1ph"
        }
      },
      "spec": {
        "podCIDR": "10.172.0.0/24",
        "externalID": "474549801021237857",
        "providerID": "gce://itri-smart-home/asia-east1-a/gke-mygke-76b971b7-node-r1ph"
      },
      "status": {
        "capacity": {
          "cpu": "1",
          "memory": "3800808Ki",
          "pods": "40"
        },
        "conditions": [
          {
            "type": "OutOfDisk",
            "status": "False",
            "lastHeartbeatTime": "2015-12-25T06:42:27Z",
            "lastTransitionTime": "2015-12-24T10:44:49Z",
            "reason": "KubeletHasSufficientDisk",
            "message": "kubelet has sufficient disk space available"
          },
          {
            "type": "Ready",
            "status": "True",
            "lastHeartbeatTime": "2015-12-25T06:42:27Z",
            "lastTransitionTime": "2015-12-24T10:45:28Z",
            "reason": "KubeletReady",
            "message": "kubelet is posting ready status"
          }
        ],
        "addresses": [
          {
            "type": "InternalIP",
            "address": "10.240.0.55"
          },
          {
            "type": "ExternalIP",
            "address": "104.155.211.198"
          }
        ],
        "daemonEndpoints": {
          "kubeletEndpoint": {
            "Port": 10250
          }
        },
        "nodeInfo": {
          "machineID": "",
          "systemUUID": "3C9751...9514B0E",
          "bootID": "16d8452...1da281ec",
          "kernelVersion": "3.16.0-0.bpo.4-amd64",
          "osImage": "Debian GNU/Linux 7 (wheezy)",
          "containerRuntimeVersion": "docker://1.8.3",
          "kubeletVersion": "v1.1.3",
          "kubeProxyVersion": "v1.1.3"
        }
      }
    }
  ]
}

Reference

single run by kubctl

kubectl run mypods \
  --image=peihsinsu/mvm-nodejs-webcapture \
  --labels=role=u2b

results matching ""

    No results matching ""