1. 程式人生 > 實用技巧 >client-go系列之3---restclient的使用

client-go系列之3---restclient的使用

0. 背景

個人主頁: https://gzh.readthedocs.io

關注容器技術、關注Kubernetes。問題或建議,請公眾號留言。

首先我通過kind建立了一個6節點的叢集,本文章中所有的操作都是在這個叢集中進行的。

通過本文的講解,希望您能瞭解如何使用client-go中的RESTClient來對資源進行操作,這裡我只是舉了最簡單的例子---pod資源獲取。

文中用到的軟體的版本如下:

  • kind
[root@xxx-wsl ~/client-go-example] kind version
kind v0.9.0 go1.15.2 linux/amd64

1. 環境準備

通過kind建立多節點的k8s叢集: 3個master節點 + 3個worker節點

[root@xxx-wsl ~/init_kind_clusters] kind create cluster --config=init_cluster.yaml
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.19.1)