首页 > 其他分享 >minikube 部署 k8s v1.28.3

minikube 部署 k8s v1.28.3

时间:2023-12-25 10:13:57浏览次数:31  
标签:kubectl kube -- nginx dashboard minikube v1.28 k8s

安装 kubeadmkubelet  kubectl

此步骤可选

下载 kubeadm

# wget -P /usr/local/bin https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubeadm

下载 kubelet

# wget -P /usr/local/bin https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubelet

下载 kubectl

# wget -P /usr/local/bin https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl

添加执行权限

# chmod +x /usr/local/bin/kube*

kubectl 命令补全

apt install -y bash-completion
kubectl completion bash > /etc/profile.d/kubectl_completion.sh
. /etc/profile.d/kubectl_completion.sh

加速 minikube 下载 kubeadmkubelet  kubectl

创建 minikube 工作目录

此目录会自动创建,本次手动创建是因为手动下载kubectl、kubeadm、kubelet,提速minikube的下载。
# mkdir /root/.minikube/cache/linux/amd64/v1.28.3 -pv

复制 kubeadmkubelet  kubectl 到指定目录

# cp /usr/local/bin/kube* /root/.minikube/cache/linux/amd64/v1.28.3/

minikube 创建 k8s 集群

# minikube start -p c1 --kubernetes-version=v1.28.3 --listen-address="0.0.0.0" --apiserver-ips=192.168.174.117,192.168.174.118,192.168.174.119 --image-mirror-country='cn'  --registry-mirror=https://0961b8c584000f7f0fd6c0041a439240.mirror.swr.myhuaweicloud.com --base-image=registry.cn-hangzhou.aliyuncs.com/google_containers/kicbase:v0.0.42 --driver=docker --container-runtime=docker --cpus=2 --memory=2200m --disk-size=20000mb  --force
* [c1] minikube v1.32.0 on Ubuntu 23.10
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Using the docker driver based on user configuration
* The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Using Docker driver with root privileges
* Starting control plane node c1 in cluster c1
* Pulling base image ...
* Creating docker container (CPUs=2, Memory=2200MB) ...
* minikube is not meant for production use. You are opening non-local traffic
! Listening to 0.0.0.0. This is not recommended and can cause a security vulnerability. Use at your own risk
! This container is having trouble accessing https://registry.cn-hangzhou.aliyuncs.com/google_containers
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
  - Using image registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
* Verifying Kubernetes components...
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "c1" cluster and "default" namespace by default

minikube dashboard

启用 dashboard

# minikube dashboard -p c1
* Enabling dashboard ...
  - Using image docker.io/kubernetesui/dashboard:v2.7.0
  - Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
* Some dashboard features require the metrics-server addon. To enable all features please run:

	minikube -p c1 addons enable metrics-server	


* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:26327/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

远程访问 dashboard 端口

# kubectl proxy --address 0.0.0.0 -p 9080 --accept-hosts='^*$'
Starting to serve on [::]:9080

远程访问 dashboard

特别说明:
 宿主机IP:192.168.174.120 
http://192.168.174.120:9080/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/workloads?namespace=default

minikube 集群信息

查看集群列表

# minikube profile list
|---------|-----------|---------|--------------|------|---------|---------|-------|--------|
| Profile | VM Driver | Runtime |      IP      | Port | Version | Status  | Nodes | Active |
|---------|-----------|---------|--------------|------|---------|---------|-------|--------|
| c1      | docker    | docker  | 192.168.49.2 | 8443 | v1.28.3 | Running |     1 |        |
|---------|-----------|---------|--------------|------|---------|---------|-------|--------|

查看集群状态

# minikube status -p c1
c1
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

查看 img

# minikube image ls --format table
|-----------------------------------------------------------------------------|---------|---------------|--------|
|                                    Image                                    |   Tag   |   Image ID    |  Size  |
|-----------------------------------------------------------------------------|---------|---------------|--------|
| docker.io/kubernetesui/metrics-scraper                                      | <none>  | 115053965e86b | 43.8MB |
| registry.cn-hangzhou.aliyuncs.com/google_containers/coredns                 | v1.10.1 | ead0a4a53df89 | 53.6MB |
| docker.io/kubernetesui/dashboard                                            | <none>  | 07655ddf2eebe | 246MB  |
| registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager | v1.28.3 | 10baa1ca17068 | 122MB  |
| registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy              | v1.28.3 | bfc896cf80fba | 73.1MB |
| registry.cn-hangzhou.aliyuncs.com/google_containers/etcd                    | 3.5.9-0 | 73deb9a3f7025 | 294MB  |
| registry.cn-hangzhou.aliyuncs.com/google_containers/pause                   | 3.9     | e6f1816883972 | 744kB  |
| registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner     | v5      | 6e38f40d628db | 31.5MB |
| registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver          | v1.28.3 | 5374347291230 | 126MB  |
| registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler          | v1.28.3 | 6d1b4fd1b182d | 60.1MB |
|-----------------------------------------------------------------------------|---------|---------------|--------|

查看 pod 信息

# kubectl  get pods -A
NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE
kube-system            coredns-6554b8b87f-phjfx                     1/1     Running   0          6m1s
kube-system            etcd-minikube                                1/1     Running   0          6m14s
kube-system            kube-apiserver-minikube                      1/1     Running   0          6m16s
kube-system            kube-controller-manager-minikube             1/1     Running   0          6m14s
kube-system            kube-proxy-qpt77                             1/1     Running   0          6m2s
kube-system            kube-scheduler-minikube                      1/1     Running   0          6m15s
kube-system            storage-provisioner                          1/1     Running   0          6m13s
kubernetes-dashboard   dashboard-metrics-scraper-7fd5cb4ddc-xxk4r   1/1     Running   0          4m1s
kubernetes-dashboard   kubernetes-dashboard-8694d4445c-j5b5t        1/1     Running   0          4m1s

部署应用

创建 ns

# kubectl create ns nginx-demo
namespace/nginx-demo created

部署 nginx

# kubectl create deployment nginx --image=nginx:1.24-alpine -n nginx-demo
deployment.apps/nginx created

创建 svc

# kubectl create svc nodeport nginx --tcp=80:80 -n nginx-demo
service/nginx created

查看 pod

# kubectl get pods -n nginx-demo -o wide
NAME                     READY   STATUS    RESTARTS   AGE   IP           NODE       NOMINATED NODE   READINESS GATES
nginx-6686c79596-hw747   1/1     Running   0          35s   10.244.0.9   minikube   <none>           <none>

查看 svc

# kubectl get svc -n nginx-demo -o wide
NAME    TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE   SELECTOR
nginx   NodePort   10.110.176.151   <none>        80:30960/TCP   62s   app=nginx

部署 client

# kubectl run client --image=ikubernetes/admin-box -it --rm --restart=Never --command -n default -- /bin/bash

通过 IP 访问 nginx

# curl 10.244.0.9 -I
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Fri, 22 Dec 2023 06:28:17 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 11 Apr 2023 17:21:57 GMT
Connection: keep-alive
ETag: "64359735-267"
Accept-Ranges: bytes

通过 svc 访问 nginx

# curl nginx.nginx-demo.svc.cluster.local -I
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Fri, 22 Dec 2023 06:41:51 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 11 Apr 2023 17:21:57 GMT
Connection: keep-alive
ETag: "64359735-267"
Accept-Ranges: bytes

通过宿主机访问 nginx

登录 minikube 集群

# minikube ssh -p c1
docker@minikube:~$

访问 nginx

docker@minikube:~$ curl 127.0.0.1:30960 -I
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Fri, 22 Dec 2023 06:44:58 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 11 Apr 2023 17:21:57 GMT
Connection: keep-alive
ETag: "64359735-267"
Accept-Ranges: bytes

参考文档

https://github.com/kubernetes/minikube/blob/master/deploy/addons/aliyun_mirror.json

标签:kubectl,kube,--,nginx,dashboard,minikube,v1.28,k8s
From: https://www.cnblogs.com/wangguishe/p/17919094.html

相关文章

  • 部署 minikube v1.32.0
    minikube介绍minikube是一个可让您在本地运行Kubernetes的工具。minikube在您的个人计算机(包括Windows、macOS和LinuxPC)上运行单节点或多节点本地Kubernetes集群,以便您可以试用Kubernetes,或进行日常开发工作。minikube环境要求1.2核CPUs2.2GB内存3.20GB......
  • k8s pod从私有仓库拉取镜像凭证配置
    方案一:通过Docker配置文件创建secret#配置.docker/config.json文件,包含了与DockerHub或其他私有仓库进行身份验证所需的凭据信息。[root@mac-25~]#cat~/.docker/config.json{ "auths":{ "registry.test.com":{ "auth":"dmlwZXIucm9ib3QuZG9ja2VyOlNUYW"......
  • k8s pv pvc
    如下代码测试本地的PVC:apiVersion:v1kind:PersistentVolumemetadata:name:mypvlabels:type:localspec:accessModes:-ReadWriteOncestorageClassName:local-pathcapacity:storage:10GihostPath:path:"/nfs"---apiVersion......
  • k8s集群搭建-2
    一、前面做过k8s的集群搭建主要是1.24版本一下的,1.24版本后"弃用docker"改用CRI了。所以这里就之前的集群安装做一下补充。老版集群地址:https://www.cnblogs.com/ll409546297/p/16718681.html二、k8s版本选择:docker-ce:20.10.24 cri-docker:0.3.8k8s:1.26.9。......
  • k8s组件、工作原理详解
    1.k8s组件  Master组件:kube-apiserver(APIServer):角色:提供集群的唯一入口,处理所有API请求。原理:接收来自客户端(kubectl、UI界面)和其他组件的请求,验证和授权请求,然后将其转发到其他组件或更新etcd中的数据。etcd:角色:分布式键值存储,保存整个集群的状......
  • K8s的常用命令
    本文旨在记录K8s使用过程中常用的CLI命令集,用作个人学习,不定期更新。1.创建资源一般创建资源会有两种方式:通过文件或者命令创建。#通过文件创建一个Deploymentkubectlcreate-f/path/to/deployment.yamlcat/path/to/deployment.yaml|kubectlcreate-f-#不过一般可......
  • k8s~ingress_service_endpoint_pod四壮士
    在Kubernetes中,Service和Endpoints是两个重要的概念,它们之间存在着密切的关系。Service:Service是Kubernetes中用于定义一组Pod的访问方式的抽象。通过创建Service,可以为一组具有相同标签的Pod提供统一的访问入口,使得客户端可以通过Service来访问这些Pod,而无需了解其具体的IP地......
  • K8S增加限制后的启动时间验证
    K8S增加限制后的启动时间验证背景前段时间看了下JVM载linux上面的启动时间,进行过一些验证.最近想着能够验证一下K8S上面的启动相关的信息所以就整理了一下.虽然没有特别好的结论,但是还是发现自己对JVM的启动和参数还是了解的不够深入.自己的几个启动参数1."-XX:......
  • k8s Ingress使用详解(云原生kubernetes)
    k8s Ingress使用详解(云原生kubernetes)目录一、什么是Ingress二、Ingress工作机制三、Ingress核心概念四、Ingress工作原理五、Ingress使用搭建Ingress环境1、获取ingress-nginx2、创建ingress-nginx部署两组service创建tomcat-nginx.yaml配置Http访问代理如何通过外网......
  • 深入 K8s 网络原理(二)- Service iptables 模式分析
    目录1.概述2.准备Service和Pods资源3.K8s里Service的实现原理3.1kube-proxy组件3.2iptables简介3.3iptables规则3.3.1Service,Pod和Host信息3.3.2从NodePort入手寻找iptables规则3.3.3从PREROUTING和OUTPUT链寻找K8s相关子链3.3.4总结下4.总结1......