searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

Minikube部署K8s环境

2024-09-05 09:26:39
66
0

安装

前置条件

  • 2 CPUs or more
  • 2GB of free memory
  • 20GB of free disk space
  • docker版本必须18以上,请自行安装版本

安装步骤

  • 下载Minikube二进制文件:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
  • 安装Minikube:
sudo install minikube-linux-amd64 /usr/local/bin/minikube
[root@localhost ~]# minikube start --force
* minikube v1.33.1 on Centos 7.9.2009
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Automatically selected the docker driver. Other choices: none, ssh
* 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 Docker driver with root privileges
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.44 ...
* Downloading Kubernetes v1.30.0 preload ...
    > preloaded-images-k8s-v18-v1...:  342.90 MiB / 342.90 MiB  100.00% 1.32 Mi
    > gcr.io/k8s-minikube/kicbase...:  337.99 MiB / 481.58 MiB  70.18% 1.25 MiB
    > index.docker.io/kicbase/sta...:  481.58 MiB / 481.58 MiB  100.00% 2.50 Mi
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.44, but successfully downloaded docker.io/kicbase/stable:v0.0.44 as a fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Found network options:
  - HTTP_PROXY=http://192.168.190.1:10811
  - HTTPS_PROXY=http://192.168.190.1:10811
  - NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.49.0/24,192.168.39.0/24
* Preparing Kubernetes v1.30.0 on Docker 26.1.1 ...
  - env HTTP_PROXY=http://192.168.190.1:10811
  - env HTTPS_PROXY=http://192.168.190.1:10811
  - env NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.49.0/24,192.168.39.0/24
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: storage-provisioner, default-storageclass
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

kubemini命令帮助

[root@localhost ~]# minikube --help
minikube provisions and manages local Kubernetes clusters optimized for development workflows.

Basic Commands:
  start            Starts a local Kubernetes cluster
  status           Gets the status of a local Kubernetes cluster
  stop             Stops a running local Kubernetes cluster
  delete           Deletes a local Kubernetes cluster
  dashboard        Access the Kubernetes dashboard running within the minikube cluster
  pause            pause Kubernetes
  unpause          unpause Kubernetes

Images Commands:
  docker-env       Provides instructions to point your terminal's docker-cli to the Docker Engine inside minikube.
(Useful for building docker images directly inside minikube)
  podman-env       Configure environment to use minikube's Podman service
  cache            Manage cache for images
  image            Manage images

Configuration and Management Commands:
  addons           Enable or disable a minikube addon
  config           Modify persistent configuration values
  profile          Get or list the current profiles (clusters)
  update-context   Update kubeconfig in case of an IP or port change

Networking and Connectivity Commands:
  service          Returns a URL to connect to a service
  tunnel           Connect to LoadBalancer services

Advanced Commands:
  mount            Mounts the specified directory into minikube
  ssh              Log into the minikube environment (for debugging)
  kubectl          Run a kubectl binary matching the cluster version
  node             Add, remove, or list additional nodes
  cp               Copy the specified file into minikube

Troubleshooting Commands:
  ssh-key          Retrieve the ssh identity key path of the specified node
  ssh-host         Retrieve the ssh host key of the specified node
  ip               Retrieves the IP address of the specified node
  logs             Returns logs to debug a local Kubernetes cluster
  update-check     Print current and latest version number
  version          Print the version of minikube
  options          Show a list of global command-line options (applies to all commands).

Other Commands:
  completion       Generate command completion for a shell
  license          Outputs the licenses of dependencies to a directory

Use "minikube <command> --help" for more information about a given command.

验证

查看集群节点详情

注意,minikube创建的node节点,有专门的IP,并非本机host的ip,如下可以看到node的ip是192.168.49.2

而本机的ip是:192.168.49.1

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:6c:41:70 brd ff:ff:ff:ff:ff:ff
    inet 192.168.190.128/24 brd 192.168.190.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::5312:7940:f3c8:4c2a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:25:83:96:31 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:25ff:fe83:9631/64 scope link 
       valid_lft forever preferred_lft forever
4: br-4e0a67cbbf73: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:35:1c:a7:13 brd ff:ff:ff:ff:ff:ff
    inet 192.168.49.1/24 brd 192.168.49.255 scope global br-4e0a67cbbf73
       valid_lft forever preferred_lft forever
    inet6 fe80::42:35ff:fe1c:a713/64 scope link 
       valid_lft forever preferred_lft forever
10: veth2b88da5@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-4e0a67cbbf73 state UP group default 
    link/ether be:2e:6b:b0:cc:f7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::bc2e:6bff:feb0:ccf7/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# minikube kubectl -- get nodes -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: Node
  metadata:
    annotations:
      kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/cri-dockerd.sock
      node.alpha.kubernetes.io/ttl: "0"
      volumes.kubernetes.io/controller-managed-attach-detach: "true"
    creationTimestamp: "2024-09-03T08:39:01Z"
    labels:
      beta.kubernetes.io/arch: amd64
      beta.kubernetes.io/os: linux
      kubernetes.io/arch: amd64
      kubernetes.io/hostname: minikube
      kubernetes.io/os: linux
      minikube.k8s.io/commit: 5883c09216182566a63dff4c326a6fc9ed2982ff
      minikube.k8s.io/name: minikube
      minikube.k8s.io/primary: "true"
      minikube.k8s.io/updated_at: 2024_09_03T04_39_04_0700
      minikube.k8s.io/version: v1.33.1
      node-role.kubernetes.io/control-plane: ""
      node.kubernetes.io/exclude-from-external-load-balancers: ""
    name: minikube
    resourceVersion: "8285"
    uid: a73f6cc6-622c-4974-b4a4-eb6ae3cc83e3
  spec:
    podCIDR: 10.244.0.0/24
    podCIDRs:
    - 10.244.0.0/24
  status:
    addresses:
    - address: 192.168.49.2
      type: InternalIP
    - address: minikube
      type: Hostname
    allocatable:
      cpu: "2"
      ephemeral-storage: 47285700Ki
      hugepages-1Gi: "0"
      hugepages-2Mi: "0"
      memory: 3861256Ki
      pods: "110"
    capacity:
      cpu: "2"
      ephemeral-storage: 47285700Ki
      hugepages-1Gi: "0"
      hugepages-2Mi: "0"
      memory: 3861256Ki
      pods: "110"
    conditions:
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has sufficient memory available
      reason: KubeletHasSufficientMemory
      status: "False"
      type: MemoryPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has no disk pressure
      reason: KubeletHasNoDiskPressure
      status: "False"
      type: DiskPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has sufficient PID available
      reason: KubeletHasSufficientPID
      status: "False"
      type: PIDPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:02Z"
      message: kubelet is posting ready status
      reason: KubeletReady
      status: "True"
      type: Ready
    daemonEndpoints:
      kubeletEndpoint:
        Port: 10250
    images:
    - names:
      - kubernetesui/dashboard@sha256:2e500d29e9d5f4a086b908eb8dfe7ecac57d2ab09d65b24f588b1d449841ef93
      sizeBytes: 245710051
    - names:
      - registry.k8s.io/etcd@sha256:44a8e24dcbba3470ee1fee21d5e88d128c936e9b55d4bc51fbef8086f8ed123b
      - registry.k8s.io/etcd:3.5.12-0
      sizeBytes: 149347661
    - names:
      - registry.k8s.io/kube-apiserver@sha256:6b8e197b2d39c321189a475ac755a77896e34b56729425590fbc99f3a96468a3
      - registry.k8s.io/kube-apiserver:v1.30.0
      sizeBytes: 116552324
    - names:
      - registry.k8s.io/kube-controller-manager@sha256:5f52f00f17d5784b5ca004dffca59710fa1a9eec8d54cebdf9433a1d134150fe
      - registry.k8s.io/kube-controller-manager:v1.30.0
      sizeBytes: 111113187
    - names:
      - registry.k8s.io/kube-proxy@sha256:ec532ff47eaf39822387e51ec73f1f2502eb74658c6303319db88d2c380d0210
      - registry.k8s.io/kube-proxy:v1.30.0
      sizeBytes: 84675401
    - names:
      - registry.k8s.io/kube-scheduler@sha256:2353c3a1803229970fcb571cffc9b2f120372350e01c7381b4b650c4a02b9d67
      - registry.k8s.io/kube-scheduler:v1.30.0
      sizeBytes: 61969366
    - names:
      - registry.k8s.io/coredns/coredns@sha256:1eeb4c7316bacb1d4c8ead65571cd92dd21e27359f0d4917f1a5822a73b75db1
      - registry.k8s.io/coredns/coredns:v1.11.1
      sizeBytes: 59820619
    - names:
      - kubernetesui/metrics-scraper@sha256:76049887f07a0476dc93efc2d3569b9529bf982b22d29f356092ce206e98765c
      sizeBytes: 43815949
    - names:
      - gcr.io/k8s-minikube/storage-provisioner@sha256:18eb69d1418e854ad5a19e399310e52808a8321e4c441c1dddad8977a0d7a944
      - gcr.io/k8s-minikube/storage-provisioner:v5
      sizeBytes: 31465472
    - names:
      - kicbase/echo-server@sha256:127ac38a2bb9537b7f252addff209ea6801edcac8a92c8b1104dacd66a583ed6
      - kicbase/echo-server:1.0
      sizeBytes: 4939776
    - names:
      - registry.k8s.io/pause@sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
      - registry.k8s.io/pause:3.9
      sizeBytes: 743952
    nodeInfo:
      architecture: amd64
      bootID: 0be19424-24ae-49a5-bfc7-8bd313fe5a4c
      containerRuntimeVersion: docker://26.1.1
      kernelVersion: 3.10.0-1160.71.1.el7.x86_64
      kubeProxyVersion: v1.30.0
      kubeletVersion: v1.30.0
      machineID: 5a3e81898e964a1d84d72256f9152109
      operatingSystem: linux
      osImage: Ubuntu 22.04.4 LTS
      systemUUID: d97355c6-fa23-4a9e-b719-b0995ddfaee2
kind: List
metadata:
  resourceVersion: ""

 

查看K8s dashboard

[root@localhost ~]# minikube dashboard
* 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 addons enable metrics-server

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

可以看到已启动

备注:这里由于在虚机上,我们可以通过ssh本地转发来访问

 

然后从浏览器打开

发布应用&访问

[root@localhost ~]# minikube kubectl -- create deployment hello-minikube --image=kicbase/echo-server:1.0
deployment.apps/hello-minikube created
[root@localhost ~]# minikube kubectl -- get deployment
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
hello-minikube   1/1     1            1           23s


[root@localhost ~]# minikube kubectl -- expose deployment hello-minikube --type=NodePort --port 8080
service/hello-minikube exposed
[root@localhost ~]# minikube kubectl -- get services
NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-minikube   NodePort    10.107.232.93   <none>        8080:30245/TCP   16s
kubernetes       ClusterIP   10.96.0.1       <none>        443/TCP          134m


#访问应用必须通过minikube给的地址访问
[root@localhost ~]# minikube service hello-minikube
|-----------|----------------|-------------|---------------------------|
| NAMESPACE |      NAME      | TARGET PORT |            URL            |
|-----------|----------------|-------------|---------------------------|
| default   | hello-minikube |        8080 | http://192.168.49.2:30245 |
|-----------|----------------|-------------|---------------------------|
* Opening service default/hello-minikube in default browser...
  http://192.168.49.2:30245

可以通过ssh本地端口转发的方式访问

通过浏览器访问:

 

参考

minikube官网:minikube start

0条评论
作者已关闭评论
q****n
20文章数
0粉丝数
q****n
20 文章 | 0 粉丝
q****n
20文章数
0粉丝数
q****n
20 文章 | 0 粉丝
原创

Minikube部署K8s环境

2024-09-05 09:26:39
66
0

安装

前置条件

  • 2 CPUs or more
  • 2GB of free memory
  • 20GB of free disk space
  • docker版本必须18以上,请自行安装版本

安装步骤

  • 下载Minikube二进制文件:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
  • 安装Minikube:
sudo install minikube-linux-amd64 /usr/local/bin/minikube
[root@localhost ~]# minikube start --force
* minikube v1.33.1 on Centos 7.9.2009
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Automatically selected the docker driver. Other choices: none, ssh
* 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 Docker driver with root privileges
* Starting "minikube" primary control-plane node in "minikube" cluster
* Pulling base image v0.0.44 ...
* Downloading Kubernetes v1.30.0 preload ...
    > preloaded-images-k8s-v18-v1...:  342.90 MiB / 342.90 MiB  100.00% 1.32 Mi
    > gcr.io/k8s-minikube/kicbase...:  337.99 MiB / 481.58 MiB  70.18% 1.25 MiB
    > index.docker.io/kicbase/sta...:  481.58 MiB / 481.58 MiB  100.00% 2.50 Mi
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.44, but successfully downloaded docker.io/kicbase/stable:v0.0.44 as a fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...
* Found network options:
  - HTTP_PROXY=http://192.168.190.1:10811
  - HTTPS_PROXY=http://192.168.190.1:10811
  - NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.49.0/24,192.168.39.0/24
* Preparing Kubernetes v1.30.0 on Docker 26.1.1 ...
  - env HTTP_PROXY=http://192.168.190.1:10811
  - env HTTPS_PROXY=http://192.168.190.1:10811
  - env NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.49.0/24,192.168.39.0/24
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
* Verifying Kubernetes components...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: storage-provisioner, default-storageclass
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

kubemini命令帮助

[root@localhost ~]# minikube --help
minikube provisions and manages local Kubernetes clusters optimized for development workflows.

Basic Commands:
  start            Starts a local Kubernetes cluster
  status           Gets the status of a local Kubernetes cluster
  stop             Stops a running local Kubernetes cluster
  delete           Deletes a local Kubernetes cluster
  dashboard        Access the Kubernetes dashboard running within the minikube cluster
  pause            pause Kubernetes
  unpause          unpause Kubernetes

Images Commands:
  docker-env       Provides instructions to point your terminal's docker-cli to the Docker Engine inside minikube.
(Useful for building docker images directly inside minikube)
  podman-env       Configure environment to use minikube's Podman service
  cache            Manage cache for images
  image            Manage images

Configuration and Management Commands:
  addons           Enable or disable a minikube addon
  config           Modify persistent configuration values
  profile          Get or list the current profiles (clusters)
  update-context   Update kubeconfig in case of an IP or port change

Networking and Connectivity Commands:
  service          Returns a URL to connect to a service
  tunnel           Connect to LoadBalancer services

Advanced Commands:
  mount            Mounts the specified directory into minikube
  ssh              Log into the minikube environment (for debugging)
  kubectl          Run a kubectl binary matching the cluster version
  node             Add, remove, or list additional nodes
  cp               Copy the specified file into minikube

Troubleshooting Commands:
  ssh-key          Retrieve the ssh identity key path of the specified node
  ssh-host         Retrieve the ssh host key of the specified node
  ip               Retrieves the IP address of the specified node
  logs             Returns logs to debug a local Kubernetes cluster
  update-check     Print current and latest version number
  version          Print the version of minikube
  options          Show a list of global command-line options (applies to all commands).

Other Commands:
  completion       Generate command completion for a shell
  license          Outputs the licenses of dependencies to a directory

Use "minikube <command> --help" for more information about a given command.

验证

查看集群节点详情

注意,minikube创建的node节点,有专门的IP,并非本机host的ip,如下可以看到node的ip是192.168.49.2

而本机的ip是:192.168.49.1

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:6c:41:70 brd ff:ff:ff:ff:ff:ff
    inet 192.168.190.128/24 brd 192.168.190.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::5312:7940:f3c8:4c2a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:25:83:96:31 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:25ff:fe83:9631/64 scope link 
       valid_lft forever preferred_lft forever
4: br-4e0a67cbbf73: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:35:1c:a7:13 brd ff:ff:ff:ff:ff:ff
    inet 192.168.49.1/24 brd 192.168.49.255 scope global br-4e0a67cbbf73
       valid_lft forever preferred_lft forever
    inet6 fe80::42:35ff:fe1c:a713/64 scope link 
       valid_lft forever preferred_lft forever
10: veth2b88da5@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-4e0a67cbbf73 state UP group default 
    link/ether be:2e:6b:b0:cc:f7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::bc2e:6bff:feb0:ccf7/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# minikube kubectl -- get nodes -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: Node
  metadata:
    annotations:
      kubeadm.alpha.kubernetes.io/cri-socket: unix:///var/run/cri-dockerd.sock
      node.alpha.kubernetes.io/ttl: "0"
      volumes.kubernetes.io/controller-managed-attach-detach: "true"
    creationTimestamp: "2024-09-03T08:39:01Z"
    labels:
      beta.kubernetes.io/arch: amd64
      beta.kubernetes.io/os: linux
      kubernetes.io/arch: amd64
      kubernetes.io/hostname: minikube
      kubernetes.io/os: linux
      minikube.k8s.io/commit: 5883c09216182566a63dff4c326a6fc9ed2982ff
      minikube.k8s.io/name: minikube
      minikube.k8s.io/primary: "true"
      minikube.k8s.io/updated_at: 2024_09_03T04_39_04_0700
      minikube.k8s.io/version: v1.33.1
      node-role.kubernetes.io/control-plane: ""
      node.kubernetes.io/exclude-from-external-load-balancers: ""
    name: minikube
    resourceVersion: "8285"
    uid: a73f6cc6-622c-4974-b4a4-eb6ae3cc83e3
  spec:
    podCIDR: 10.244.0.0/24
    podCIDRs:
    - 10.244.0.0/24
  status:
    addresses:
    - address: 192.168.49.2
      type: InternalIP
    - address: minikube
      type: Hostname
    allocatable:
      cpu: "2"
      ephemeral-storage: 47285700Ki
      hugepages-1Gi: "0"
      hugepages-2Mi: "0"
      memory: 3861256Ki
      pods: "110"
    capacity:
      cpu: "2"
      ephemeral-storage: 47285700Ki
      hugepages-1Gi: "0"
      hugepages-2Mi: "0"
      memory: 3861256Ki
      pods: "110"
    conditions:
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has sufficient memory available
      reason: KubeletHasSufficientMemory
      status: "False"
      type: MemoryPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has no disk pressure
      reason: KubeletHasNoDiskPressure
      status: "False"
      type: DiskPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:00Z"
      message: kubelet has sufficient PID available
      reason: KubeletHasSufficientPID
      status: "False"
      type: PIDPressure
    - lastHeartbeatTime: "2024-09-03T11:17:45Z"
      lastTransitionTime: "2024-09-03T08:39:02Z"
      message: kubelet is posting ready status
      reason: KubeletReady
      status: "True"
      type: Ready
    daemonEndpoints:
      kubeletEndpoint:
        Port: 10250
    images:
    - names:
      - kubernetesui/dashboard@sha256:2e500d29e9d5f4a086b908eb8dfe7ecac57d2ab09d65b24f588b1d449841ef93
      sizeBytes: 245710051
    - names:
      - registry.k8s.io/etcd@sha256:44a8e24dcbba3470ee1fee21d5e88d128c936e9b55d4bc51fbef8086f8ed123b
      - registry.k8s.io/etcd:3.5.12-0
      sizeBytes: 149347661
    - names:
      - registry.k8s.io/kube-apiserver@sha256:6b8e197b2d39c321189a475ac755a77896e34b56729425590fbc99f3a96468a3
      - registry.k8s.io/kube-apiserver:v1.30.0
      sizeBytes: 116552324
    - names:
      - registry.k8s.io/kube-controller-manager@sha256:5f52f00f17d5784b5ca004dffca59710fa1a9eec8d54cebdf9433a1d134150fe
      - registry.k8s.io/kube-controller-manager:v1.30.0
      sizeBytes: 111113187
    - names:
      - registry.k8s.io/kube-proxy@sha256:ec532ff47eaf39822387e51ec73f1f2502eb74658c6303319db88d2c380d0210
      - registry.k8s.io/kube-proxy:v1.30.0
      sizeBytes: 84675401
    - names:
      - registry.k8s.io/kube-scheduler@sha256:2353c3a1803229970fcb571cffc9b2f120372350e01c7381b4b650c4a02b9d67
      - registry.k8s.io/kube-scheduler:v1.30.0
      sizeBytes: 61969366
    - names:
      - registry.k8s.io/coredns/coredns@sha256:1eeb4c7316bacb1d4c8ead65571cd92dd21e27359f0d4917f1a5822a73b75db1
      - registry.k8s.io/coredns/coredns:v1.11.1
      sizeBytes: 59820619
    - names:
      - kubernetesui/metrics-scraper@sha256:76049887f07a0476dc93efc2d3569b9529bf982b22d29f356092ce206e98765c
      sizeBytes: 43815949
    - names:
      - gcr.io/k8s-minikube/storage-provisioner@sha256:18eb69d1418e854ad5a19e399310e52808a8321e4c441c1dddad8977a0d7a944
      - gcr.io/k8s-minikube/storage-provisioner:v5
      sizeBytes: 31465472
    - names:
      - kicbase/echo-server@sha256:127ac38a2bb9537b7f252addff209ea6801edcac8a92c8b1104dacd66a583ed6
      - kicbase/echo-server:1.0
      sizeBytes: 4939776
    - names:
      - registry.k8s.io/pause@sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
      - registry.k8s.io/pause:3.9
      sizeBytes: 743952
    nodeInfo:
      architecture: amd64
      bootID: 0be19424-24ae-49a5-bfc7-8bd313fe5a4c
      containerRuntimeVersion: docker://26.1.1
      kernelVersion: 3.10.0-1160.71.1.el7.x86_64
      kubeProxyVersion: v1.30.0
      kubeletVersion: v1.30.0
      machineID: 5a3e81898e964a1d84d72256f9152109
      operatingSystem: linux
      osImage: Ubuntu 22.04.4 LTS
      systemUUID: d97355c6-fa23-4a9e-b719-b0995ddfaee2
kind: List
metadata:
  resourceVersion: ""

 

查看K8s dashboard

[root@localhost ~]# minikube dashboard
* 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 addons enable metrics-server

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

可以看到已启动

备注:这里由于在虚机上,我们可以通过ssh本地转发来访问

 

然后从浏览器打开

发布应用&访问

[root@localhost ~]# minikube kubectl -- create deployment hello-minikube --image=kicbase/echo-server:1.0
deployment.apps/hello-minikube created
[root@localhost ~]# minikube kubectl -- get deployment
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
hello-minikube   1/1     1            1           23s


[root@localhost ~]# minikube kubectl -- expose deployment hello-minikube --type=NodePort --port 8080
service/hello-minikube exposed
[root@localhost ~]# minikube kubectl -- get services
NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-minikube   NodePort    10.107.232.93   <none>        8080:30245/TCP   16s
kubernetes       ClusterIP   10.96.0.1       <none>        443/TCP          134m


#访问应用必须通过minikube给的地址访问
[root@localhost ~]# minikube service hello-minikube
|-----------|----------------|-------------|---------------------------|
| NAMESPACE |      NAME      | TARGET PORT |            URL            |
|-----------|----------------|-------------|---------------------------|
| default   | hello-minikube |        8080 | http://192.168.49.2:30245 |
|-----------|----------------|-------------|---------------------------|
* Opening service default/hello-minikube in default browser...
  http://192.168.49.2:30245

可以通过ssh本地端口转发的方式访问

通过浏览器访问:

 

参考

minikube官网:minikube start

文章来自个人专栏
云技术专栏
20 文章 | 1 订阅
0条评论
作者已关闭评论
作者已关闭评论
4
3