Tabla de contenido
Texto original "Uso de kubeadm para instalar Kubernetes 1.15"
问题1: no se encuentra el recurso solicitado
Problema 2: pod ESTADO: ImagePullBackOff
Texto original "Uso de kubeadm para instalar Kubernetes 1.15"
Instalación de timón
Helm consiste en la herramienta de línea de comandos helm del lado del cliente y el timón del lado del servidor. La instalación de Helm es muy simple. Descargue la herramienta de línea de comandos de helm en /usr/local/bin del nodo maestro node1, la versión 2.14.1 descargada aquí:
curl -O https://get.helm.sh/helm-v2.14.1-linux-amd64.tar.gz
tar -zxvf helm-v2.14.1-linux-amd64.tar.gz
cd linux-amd64/
cp helm /usr/local/bin/
Para instalar el timón del servidor, también debe configurar la herramienta kubectl y el archivo kubeconfig en esta máquina para asegurarse de que la herramienta kubectl pueda acceder al apiserver en esta máquina y usarlo normalmente. El nodo node1 aquí se configuró con kubectl.
Debido a que Kubernetes APIServer ha habilitado el control de acceso RBAC, debe crear la cuenta de servicio utilizada por tiller: tiller y asignarle las funciones adecuadas. Para obtener más información, consulte Control de acceso basado en funciones en la documentación de Helm . En aras de la simplicidad, asígnele directamente el ClusterRole integrado de cluster-admin. Cree el archivo helm-rbac.yaml :
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
implementar:
kubectl create -f helm-rbac.yaml
serviceaccount/tiller created
clusterrolebinding.rbac.authorization.k8s.io/tiller created
A continuación, use el timón para desplegar el timón:
helm init --service-account tiller --skip-refresh
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/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
问题1: no se encuentra el recurso solicitado
# helm init --service-account timón --skip-refresh
Error:
Error: error de instalación: el servidor no pudo encontrar el recurso solicitado
----El servidor no puede encontrar el recurso solicitado
Después de buscar en una serie de artículos, finalmente encontré la "Guía de Kubernetes" para resolver:
Para las versiones anteriores a Kubernetes v1.16.0, se pueden encontrar Error: error installing: the server could not find the requested resource
errores . Esto se debe a extensions/v1beta1
que se apps/v1
reemplazó, la solución es:
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' | kubectl apply -f -
Actualizar la lista de gráficos:
helm repo update
El resultado está bien:
Problema 2: pod ESTADO: ImagePullBackOff
Ver estado encontrado ESTADO: ImagePullBackOff
# tiller默认被部署在k8s集群中的 kube-system 这个namespace下
# kubectl get pods -n kube-system
Ver eventos de grupo
# kubectl describe pod tiller-deploy-cf88b7d9-zlb7s -n kube-system
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 11m default-scheduler Successfully assigned kube-system/tiller-deploy-cf88b7d9-zlbe2
Normal Pulling 8m44s (x4 over 11m) kubelet, node2 Pulling image "gcr.io/kubernetes-helm/tiller:v2.14.1"
Warning Failed 8m29s (x4 over 10m) kubelet, node2 Failed to pull image "gcr.io/kubernetes-helm/tiller:v2.14.1"or: code = Unknown desc = Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting foron (Client.Timeout exceeded while awaiting headers)
Warning Failed 8m29s (x4 over 10m) kubelet, node2 Error: ErrImagePull
Normal BackOff 8m15s (x6 over 10m) kubelet, node2 Back-off pulling image "gcr.io/kubernetes-helm/tiller:v2.14.
Warning Failed 54s (x35 over 10m) kubelet, node2 Error: ImagePullBackOff
Obviamente, la adquisición de la imagen gcr.io/kubernetes-helm/tiller:v2.14 falló.
Necesidad de extraer manualmente la imagen
1. Ver imágenes disponibles
[root@node1 linux-amd64]# docker search tiller
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
jessestuart/tiller Nightly multi-architecture (amd64, arm64, ar… 19 [OK]
sapcc/tiller Mirror of https://gcr.io/kubernetes-helm/til… 9
ist0ne/tiller https://gcr.io/kubernetes-helm/tiller 3 [OK]
rancher/tiller 2
jmgao1983/tiller from gcr.io/kubernetes-helm/tiller 2 [OK]
ibmcom/tiller Docker Image for IBM Cloud private-CE (Commu… 1
luxas/tiller 1
itinerisltd/tiller [Deprecated] Use https://circleci.com/orbs/r… 1
ansibleplaybookbundle/tiller-apb An APB that deploys tiller for use with helm. 1 [OK]
cfplatformeng/tiller-ubuntu 0
Elegí: sapcc/tiller Mirror de https://gcr.io/kubernetes-helm/til…
2. Ve a dockerhub para confirmar
3. Descarga la imagen:
docker pull sapcc/tiller:v2.16.3
Ver espejo local
[root@node1 linux-amd64]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sapcc/tiller v2.16.3 6a79bebf87f5 7 days ago 91.2MB
...
4. Edite el archivo de configuración
# kubectl edit deployment tiller-deploy -n kube-system
...
template:
metadata:
creationTimestamp: null
labels:
app: helm
name: tiller
spec:
automountServiceAccountToken: true
containers:
- env:
- name: TILLER_NAMESPACE
value: kube-system
- name: TILLER_HISTORY_MAX
value: "0"
# image:改成手动下载的镜像的 NAME:TAG
image: sapcc/tiller:v2.16.3
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /liveness
port: 44135
scheme: HTTP
initialDelaySeconds: 1
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: tiller
...
Otra forma es
Encuentre la estrategia de extracción de imágenes y realice los siguientes cambios:
imagePullPolicy:
Never
IfNotPresent :如果本地存在镜像就优先使用本地镜像。 Never:直接不再去拉取镜像了,使用本地的;如果本地不存在就报异常了
5. Luego actualice la lista de gráficos
helm repo update
7. Verifique el estado de la cápsula, ¡En ejecución!
[root@node1 linux-amd64]# kubectl get pod -n kube-system -l app=helm
NAME READY STATUS RESTARTS AGE
tiller-deploy-655f8745d9-zgkwc 1/1 Running 0 98m
referencia:
https://feisky.gitbooks.io/kubernetes/content/apps/helm.html