Panel de administración de clúster de Kube Registro de compilación amplio y clúster nginx

La necesidad de la gestión de clústeres

Ha llegado la era de los contenedores, cómo gestionar los contenedores en lotes es una habilidad vital

Tutorial de instalación de una sola máquina

https://blog.csdn.net/weixin_41632383/article/details/107878329

Instalar el complemento de red

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Construye dashbroad

Descarga el contenedor de implementación

contenido recomendado.yaml

Para descargar recursos, vaya a https://github.com/mengkaibulusili/k8sConfigFils

Restablecer clúster

kubeadm  reset
rm -rf $HOME/.kube
kubeadm init  --pod-network-cidr=10.0.0.0/24 

#解决错误 The connection to the server localhost:8080 was refused 
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Aplicación yaml

kubectl apply -f recommended.yaml

Crea un archivo para configurar usuarios

adduser.yaml
ClusterRoleBinding.yaml

Configurar el token de inicio de sesión

// 创建用户
kubectl apply -f C:\Users\73444\Desktop\kbs\dashbroad\adduser.yaml
// 绑定用户和服务
kubectl apply -f C:\Users\73444\Desktop\kbs\dashbroad\ClusterRoleBinding.yaml

// 生成并查看秘钥
 kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | sls admin-user | ForEach-Object {
     
      $_ -Split '\s+' } | Select -First 1)

output:
Name:         admin-user-token-h9lvx
Namespace:    kubernetes-dashboard
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: admin-user
              kubernetes.io/service-account.uid: 61e3d84e-b871-469f-abb7-b50c8a325d76

Type:  kubernetes.io/service-account-token

Data
====
token:      eyJhbGciOiJ
ca.crt:     1025 bytes
namespace:  20 bytes

Visita dashbroad

kubectl proxy
然后访问网址

http: // localhost: 8001 / api / v1 / namespaces / kubernetes-dashboard / services / https: kubernetes-dashboard: / proxy /

Solo ingrese la clave

Inserte la descripción de la imagen aquí

Basado en el establecimiento de minikube, los servicios nginx están expuestos

Actualización en caliente, introducción a la expansión en caliente

Sin embargo, cuando se actualizan y amplían varios subnodos de servicio, k8s realizará la migración del servicio sin problemas. Solo es necesario modificar la configuración correspondiente en el archivo de configuración.

Implementación, actualización y expansión de servicios nginx

#提交一个 nginx deployment;
kubectl apply  -f  https://k8s.io/examples/application/deployment.yaml
 
#升级 nginx deployment;
kubectl apply -f  https://k8s.io/examples/application/deployment-update.yaml

#扩容 nginx deployment。
kubectl apply -f  https://k8s.io/examples/application/deployment-scale.yaml

Ver los pods de nginx iniciados

kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-574b87c764-hn9p5   1/1     Running   0          56m
nginx-deployment-574b87c764-lc9h2   1/1     Running   0          56m

Ver la implementación de nginx

kubectl get deployment
NAME               READY   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   2/2     2            2           55m

Exponer el servicio nginx

 kubectl expose deployment/nginx-deployment --type="NodePort" --port 80

Ver servicio nginx

kubectl get service
NAME               TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
kubernetes         ClusterIP   10.96.0.1    <none>        443/TCP        26h
nginx-deployment   NodePort    10.96.0.88   <none>        80:31174/TCP   26m

Eliminar servicio

kubectl delete service nginx-deployment

Puerto de servicio externo fijo

apiVersion: v1 # for versions before 1.9.0 use apps/v1beta2

kind: Service
metadata:
  name: nginx-service
spec:
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    # 固定端口数值,必须是配置文件范围内
    nodePort: 30100
  type: NodePort
  selector:
    app: nginx

llevado a cabo

 kubectl create -f C:\Users\73444\Desktop\service.yaml

Supongo que te gusta

Origin blog.csdn.net/qq_43373608/article/details/107591867
Recomendado
Clasificación