Author Topic: ติดตั้ง kubectl on mac  (Read 4076 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
ติดตั้ง kubectl on mac
« on: พฤษภาคม 24, 2017, 08:39:52 PM »
ติดตั้ง kubectl on mac

ถ้าหากรันใน folder google-cloud-sdk
อาจจะเจอ error

ERROR: (gcloud.components.install) Your current working directory is inside the Cloud SDK install root: /Users/watthanachaikekhua/remote/google-cloud-sdk.  In order to perform this update, run the command from outside of this directory.

ทำการแก้ไขโดยออกมา 1 step ครับแล้วเรียกรัน
# cd ..
# ./google-cloud-sdk/gcloud components install kubectl


Your current Cloud SDK version is: 14x.0.0
Installing components from version: 14x.0.0

┌─────────────────────────────────────────────────┐
│       These components will be installed.       │
├────────────────────────────┬─────────┬──────────┤
│            Name            │ Version │   Size   │
├────────────────────────────┼─────────┼──────────┤
│ kubectl                    │         │          │
│ kubectl (Mac OS X, x86_64) │   1.5.4 │ 11.4 MiB │
└────────────────────────────┴─────────┴──────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?  Y

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ติดตั้ง kubectl on mac
« Reply #1 on: พฤษภาคม 24, 2017, 09:49:12 PM »
https://github.com/kubernetes/kubernetes/issues/30617
เพิ่มเติมการ connect kubectl ผ่าน mac

ถ้ารัน command check version แล้วมี error เกี่ยวกับ could not find default credentials
#kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.3", GitCommit:"c6411395e09da356c608896d3d9725acab821418", GitTreeState:"clean", BuildDate:"2016-07-22T20:29:38Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}
error: google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

ทำการ generate credentials แล้วนำมารันใน command line on mac
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json"

แล้วทำการ รันอีกรอบดูครับ ก็จะสามารถเรียกใช้งานได้ปกติ
$gcloud auth application-default login
$gcloud config set project-name

$gcloud config set compute/zone asia-east1-b

ทำการเช็ค version kubernetes
$kubectl version
ทำการเช็ค config ของ kubernetes
$kubectl config view

ค้นหา pods
$kubectl get pods

ทำการเข้าไปยัง pods นั้นๆ
$kubectl exec -it pods_name -- bash
« Last Edit: พฤษภาคม 24, 2017, 10:14:58 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ติดตั้ง kubectl on mac
« Reply #2 on: พฤษภาคม 27, 2017, 04:54:47 PM »
OK Work