[容器] Helm的安裝和使用

helm安裝與使用介紹

helm與EKS是無縫結(jié)合的赌蔑,按照AWS教程即可

helm 與 Amazon EKS 配合使用教程

了解了下helm客戶端和服務(wù)端tiller的區(qū)別

The Helm Client is a command-line client for end users. The client is responsible for the following domains:

  • Local chart development
  • Managing repositories
  • Interacting with the Tiller server
  • Sending charts to be installed
  • Asking for information about releases
  • Requesting upgrading or uninstalling of existing releases

The Tiller Server is an in-cluster server that interacts with the Helm client, and interfaces with the Kubernetes API server. The server is responsible for the following:

  • Listening for incoming requests from the Helm client
  • Combining a chart and configuration to build a release
  • Installing charts into Kubernetes, and then tracking the subsequent release
  • Upgrading and uninstalling charts by interacting with Kubernetes

1 helm的安裝

# 參見helm官方社區(qū)的教程直接brew安裝
$ brew install kubernetes-helm

2 介紹tiller的部署

tiller是helm的服務(wù)端滞伟,helm客戶端指令給到tiller部署EKS上的服務(wù)。AWS為了安全考慮建議tiller部署在本地掀泳,helm與本地的tiller交互土浸,但缺點(diǎn)是每次helm指令都需要保證tiller服務(wù)在線。作為初學(xué)者啤它,我直接將tiller部署到EKS上了。

3 給tiller先設(shè)定RBAC (Role-based Access Control)

helm init會將tiller服務(wù)部署好,同時(shí)測試helm repo update也成功了变骡,但是helm ls遇到了如下錯(cuò)誤:

$ helm ls
Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list resource "configmaps" in API group "" in the namespace "kube-system"

原因是kubernetes對部署的服務(wù)有api權(quán)限控制离赫,說白了就是tiller服務(wù)沒有權(quán)限訪問kubernetes的資源,需要賦予tiller一個(gè)role且綁定必要的權(quán)限塌碌,來做一下吧渊胸。

In Kubernetes, granting a role to an application-specific service account is a best practice to ensure that your application is operating in the scope that you have specified.

創(chuàng)建一個(gè)yaml描述文件,能看到該文件創(chuàng)建了一個(gè)ServiceAccount台妆,同時(shí)做了一個(gè)ClusterRoleBinding蹬刷。注意其中name、namespace取值要填寫正確频丘。

# rbac-config.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tiller
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tiller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: tiller
    namespace: kube-system

應(yīng)用該yaml文件

$ kubectl create -f rbac-config.yaml
serviceaccount "tiller" created
clusterrolebinding.rbac.authorization.k8s.io "tiller" created

4 helm init初始化tiller

$ helm init --service-account tiller

表明使用上面的含有權(quán)限的賬戶办成,然后再運(yùn)行不會報(bào)錯(cuò)了

$ helm ls

上述指令默認(rèn)將tiller安裝到EKS上,同時(shí)tiller-namespace默認(rèn)是kube-system搂漠,可以根據(jù)實(shí)際需求更改為本地部署或使用獨(dú)立的tiller-namespace

5 使用helm部署nginx

EKS讓參考helm官網(wǎng)的安裝服務(wù)示例迂卢,helm上面的是mysql,但是驗(yàn)證mysql還需要client程序桐汤,blabla... 可以使用更簡單的nginx來玩一下而克。

$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories

$ helm repo list
NAME    URL
stable  https://kubernetes-charts.storage.googleapis.com
local   http://127.0.0.1:8879/charts
bitnami https://charts.bitnami.com/bitnami

$ helm install --name my-nginx bitnami/nginx
NAME:   my-nginx
LAST DEPLOYED: Thu Aug 29 17:58:29 2019
NAMESPACE: default
STATUS: DEPLOYED
... ...
NOTES:
Get the NGINX URL:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w my-nginx'

  export SERVICE_IP=$(kubectl get svc --namespace default my-nginx --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
  echo "NGINX URL: http://$SERVICE_IP/"

最后使用kubectl可以看到部署好的nignx服務(wù),不過dns生效需要5分鐘左右的時(shí)間怔毛,要耐心等一下员萍。

$ kubectl get svc --namespace default -w my-nginx -o wide                                                                                                                      1 ?
NAME       TYPE           CLUSTER-IP      EXTERNAL-IP                                  PORT(S)        AGE       SELECTOR
my-nginx   LoadBalancer   10.100.171.65   a8d4d4bdbdbdbd.us-west-2.elb.amazonaws.com   80:31464/TCP   48s       app=my-nginx
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市拣度,隨后出現(xiàn)的幾起案子碎绎,更是在濱河造成了極大的恐慌,老刑警劉巖抗果,帶你破解...
    沈念sama閱讀 221,430評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件筋帖,死亡現(xiàn)場離奇詭異,居然都是意外死亡冤馏,警方通過查閱死者的電腦和手機(jī)日麸,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,406評論 3 398
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來逮光,“玉大人代箭,你說我怎么就攤上這事√楦眨” “怎么了嗡综?”我有些...
    開封第一講書人閱讀 167,834評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長副女。 經(jīng)常有香客問我蛤高,道長,這世上最難降的妖魔是什么碑幅? 我笑而不...
    開封第一講書人閱讀 59,543評論 1 296
  • 正文 為了忘掉前任戴陡,我火速辦了婚禮,結(jié)果婚禮上沟涨,老公的妹妹穿的比我還像新娘恤批。我一直安慰自己,他們只是感情好裹赴,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,547評論 6 397
  • 文/花漫 我一把揭開白布喜庞。 她就那樣靜靜地躺著,像睡著了一般棋返。 火紅的嫁衣襯著肌膚如雪延都。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,196評論 1 308
  • 那天睛竣,我揣著相機(jī)與錄音晰房,去河邊找鬼。 笑死射沟,一個(gè)胖子當(dāng)著我的面吹牛殊者,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播验夯,決...
    沈念sama閱讀 40,776評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼猖吴,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了挥转?” 一聲冷哼從身側(cè)響起海蔽,我...
    開封第一講書人閱讀 39,671評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎绑谣,沒想到半個(gè)月后准潭,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,221評論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡域仇,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,303評論 3 340
  • 正文 我和宋清朗相戀三年刑然,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片暇务。...
    茶點(diǎn)故事閱讀 40,444評論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡泼掠,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出垦细,到底是詐尸還是另有隱情择镇,我是刑警寧澤,帶...
    沈念sama閱讀 36,134評論 5 350
  • 正文 年R本政府宣布括改,位于F島的核電站腻豌,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜吝梅,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,810評論 3 333
  • 文/蒙蒙 一虱疏、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧苏携,春花似錦做瞪、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,285評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至纱扭,卻和暖如春牍帚,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背乳蛾。 一陣腳步聲響...
    開封第一講書人閱讀 33,399評論 1 272
  • 我被黑心中介騙來泰國打工履羞, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人屡久。 一個(gè)月前我還...
    沈念sama閱讀 48,837評論 3 376
  • 正文 我出身青樓忆首,卻偏偏與公主長得像,于是被迫代替她去往敵國和親被环。 傳聞我的和親對象是個(gè)殘疾皇子糙及,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,455評論 2 359

推薦閱讀更多精彩內(nèi)容