kubernets helm chart 常用命令

1、helm安装

软件准备

helm v2由客户端helm cli工具和服务器tiller两部分组成。

下载地址:https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-linux-amd64.tar.gz

release地址:https://github.com/helm/helm/releases

运行tiller服务器

本地运行直接执行tiller即可 ./tiller

初始化helm

 
 
 
 
 
 
 
 
 
helm init --client-only
#Creating /root/.helm
#Creating /root/.helm/repository
#Creating /root/.helm/repository/cache
#Creating /root/.helm/repository/local
#Creating /root/.helm/plugins
#Creating /root/.helm/starters
#Creating /root/.helm/repository/repositories.yaml
#$HELM_HOME has been configured at /root/.helm.

参数:

--client-only:只初始化helm,不在集群内安装tiller,只会在helm home目录下创建配置文件

--home:helm 文件存储目录,默认/root/.helm,若初始化时修改了该参数,后续的helm调用也需要指定home路径。因此可直接修改环境变量$HELM_HOME来实现。

2.helm push 安装

helm-push插件地址 https://github.com/chartmuseum/helm-push/

下载后,将其解压到.helm/plugins/helm-push.git下

3、helm常用命令

helm install --name test .  在chart目录内,部署chart

helm del --purge test 删除test部署

helm push mychart-0.1.0.tgz repo 上传chart包

helm repo add --username username --password password repo_name repo_address/username 增加repo
helm repo list 列举已添加的charts repo
helm repo remove repo_name 移除repo
helm search keyword -l 列出repo提供的带有关键字的模板
helm fetch --version version repo/chart_name 下载模板到本地
helm install /root/testlink-4.0.1.tgz --tls 安装模板实例
helm list --tls 列出所有仓库的charts实例
helm plugin install https://github.com/chartmuseum/helm-push

4、k8s常用命令
 kubectl get pod/deployment/svc -n name1 查看name1 namespace下的pos、svc、deployment
kubectl get pod/svc/deployment --all-namcpaces 查看所有namespace下的
kubectl describe pod/deployment xxx -n name1 查看pod/deployment描述
 查看pod 日志 (如果pod有多个容器需要加-c 容器名)kubectl logs xxx -n kube-system
 删除应用(先确定是由说明创建的,再删除对应的kind):kubectl delete deployment xxx -n kube-system

 导出配置文件:

导出proxy
  kubectl get ds -n kube-system -l k8s-app=kube-proxy -o yaml>kube-proxy-ds.yaml
  导出kube-dns
  kubectl get deployment -n kube-system -l k8s-app=kube-dns -o yaml >kube-dns-dp.yaml
  kubectl get services -n kube-system -l k8s-app=kube-dns -o yaml >kube-dns-services.yaml
  导出所有 configmap
  kubectl get configmap -n kube-system -o wide -o yaml > configmap.yaml

helm运行:helm install --name name1 .

删除:helm del --purge name1

k8s进入容器的方法:

<1>

kubectl get pods   #查看所有正在运行的pod

NAME                            READY     STATUS    RESTARTS   AGE

nginx-56b8c64cb4-t97vb          1/1       Running   3          1d

<2>

➜  ~ kubectl exec -it nginx-56b8c64cb4-t97vb -- /bin/bash      #假如当前pod只有一个容器,运行以下命令即可

root@nginx-56b8c64cb4-t97vb:/# ps -ef

UID        PID  PPID  C STIME TTY          TIME CMD

root         1     0  0 14:45 ?        00:00:00 nginx: master process nginx -g daemon off;

<3>假如一个pod里有多个容器,用--container or -c 参数。例如:假如这里有个Pod名为my-pod,这个Pod有两个容器,分别名为main-app 和 helper-app,下面的命令将打开到main-app的shell的容器里。

kubectl exec -it my-pod --container main-app -- /bin/bash

查看 Pod 在节点上的资源分配情况(Request、Limits):kubectl describe node

查看节点的资源使用情况:kubectl top node

查看 Pod 资源使用情况:kubectl top pod

posted @ 2020-12-23 10:51  鸭子船长  阅读(363)  评论(0编辑  收藏  举报