kubernetes 五种核心资源对象简介

Namespace

  • Namespace是kubernetes系统中的一种非常重要资源,它的主要作用是用来实现多套环境的资源隔离或者多租户的资源隔离

  • 默认情况下,kubernetes集群中的所有的Pod都是可以相互访问的。但是在实际中,可能不想让两个Pod之间进行互相的访问,那此时就可以将两个Pod划分到不同的namespace下。kubernetes通过将集群内部的资源分配到不同的Namespace中,可以形成逻辑上的"组",以方便不同的组的资源进行隔离使用和管理。

  • 可以通过kubernetes的授权机制,将不同的namespace交给不同租户进行管理,这样就实现了多租户的资源隔离。此时还能结合kubernetes的资源配额机制,限定不同租户能占用的资源,例如CPU使用量、内存使用量等等,来实现租户可用资源的管理。
    kubernetes 五种核心资源对象简介_第1张图片

kubernetes在集群启动之后,会默认创建几个namespace

[root@k8s-master-01 ~]# kubectl get namespace
NAME              STATUS   AGE
default           Active   72m		 #  所有未指定Namespace的对象都会被分配在default命名空间
kube-node-lease   Active   72m		 #  集群节点之间的心跳维护,v1.13开始引入
kube-public       Active   72m		 #  此命名空间下的资源可以被所有人访问(包括未认证用户)
kube-system       Active   72m		 #  所有由Kubernetes系统创建的资源都处于这个命名空间

namespace资源的具体操作

# 1. 查看所有的ns  命令:kubectl get ns
[root@k8s-master-01 ~]# kubectl get ns
NAME              STATUS   AGE
default           Active   75m
kube-node-lease   Active   75m
kube-public       Active   75m
kube-system       Active   75m

# 2. 查看指定的ns   命令:kubectl get ns ns名称
[root@k8s-master-01 ~]# kubectl get ns default
NAME      STATUS   AGE
default   Active   75m

# 3. 指定输出格式  命令:kubectl get ns ns名称  -o 格式参数
# kubernetes支持的格式有很多,比较常见的是wide、json、yaml
[root@k8s-master-01 ~]# kubectl get ns default -o json
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "creationTimestamp": "2021-08-05T10:20:27Z",
        "labels": {
            "kubernetes.io/metadata.name": "default"
        },
        "name": "default",
        "resourceVersion": "209",
        "uid": "ea32b83d-3a22-46a0-8901-8183e4db4e47"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Active"
    }
}

# 4. 查看ns详情  命令:kubectl describe ns ns名称
[root@k8s-master-01 ~]# kubectl describe ns default
Name:         default
Labels:       kubernetes.io/metadata.name=default
Annotations:  
Status:       Active		# Active 命名空间正在使用中  Terminating 正在删除命名空间

# ResourceQuota		针对namespace做的资源限制
# LimitRange	针对namespace中的每个组件做的资源限制
No resource quota.
No LimitRange resource.

# 创建namespace
[root@k8s-master-01 ~]# kubectl create ns dev
namespace/dev created

# 删除namespace
[root@k8s-master-01 ~]# kubectl delete ns dev
namespace "dev" deleted

配置方式

# 首先准备一个yaml文件
[root@k8s-master-01 ~]# vim dev.yml
apiVersion: v1			# 版本号
kind: Namespace			# 名称空间
metadata:				# 名称空间的元数据
  name: dev

# 然后就可以执行对应的创建和删除命令了
# 创建一个名称空间
[root@k8s-master-01 ~]# kubectl create -f dev.yml 
namespace/dev created

# 删除一个名称空间
[root@k8s-master-01 ~]# kubectl delete -f dev.yml 
namespace "dev" deleted

Pod

Pod是kubernetes集群进行管理的最小单元,程序要运行必须部署在容器中,而容器必须存在于Pod中。

Pod可以认为是容器的封装,一个Pod中可以存在一个或者多个容器。
kubernetes 五种核心资源对象简介_第2张图片

kubernetes在集群启动之后,集群中的各个组件也都是以Pod方式运行的。可以通过下面命令查看:

# 查看kubernetes集群各个组件的Pod信息
[root@k8s-master-01 ~]# kubectl get pod -n kube-system
NAME                                    READY   STATUS    RESTARTS   AGE
coredns-7d7778b79-dlvkp                 1/1     Running   1          125m
coredns-7d7778b79-sdxkg                 1/1     Running   1          125m
etcd-k8s-master-01                      1/1     Running   1          125m
kube-apiserver-k8s-master-01            1/1     Running   1          125m
kube-controller-manager-k8s-master-01   1/1     Running   1          125m
kube-flannel-ds-5r7qf                   1/1     Running   1          123m
kube-flannel-ds-jjrq5                   1/1     Running   1          122m
kube-flannel-ds-qlh45                   1/1     Running   1          122m
kube-proxy-srj9w                        1/1     Running   1          122m
kube-proxy-vhk69                        1/1     Running   1          122m
kube-proxy-zcfc2                        1/1     Running   1          125m
kube-scheduler-k8s-master-01            1/1     Running   1          125m

kubernetes没有提供单独运行Pod的命令,都是通过Pod控制器来实现的。

命令格式: kubectl run (pod名称) [参数] 

# --image  指定Pod的镜像
# --port   指定端口
# --namespace  指定namespace
[root@k8s-master-01 ~]# kubectl run nginx --image=nginx --port=80 --namespace dev	 
pod/nginx created

pod资源的具体操作

# 创建名称空间
[root@k8s-master-01 ~]# kubectl create ns dev
namespace/dev created

# 创建一个pod节点,不指定pod控制器
[root@k8s-master-01 ~]# kubectl run nginx --image=nginx --port=80 --namespace dev	 
pod/nginx created

# 查看Pod基本信息
[root@k8s-master-01 ~]# kubectl get pods -n dev
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          3m40s

# 查看Pod的详细信息
[root@k8s-master-01 ~]# kubectl describe pod nginx -n dev
Name:         nginx
Namespace:    dev
Priority:     0
Node:         k8s-node-01/192.168.15.12
Start Time:   Thu, 05 Aug 2021 21:49:40 +0800
Labels:       run=nginx
Annotations:  
Status:       Running
IP:           10.244.1.5
IPs:
  IP:  10.244.1.5
Containers:
  nginx:
    Container ID:   docker://3d7d82534a251658d36d14d7e7ff3a1e9bef1bdc5205bfa9c8665baffeb57a59
    Image:          nginx
    Image ID:       docker-pullable://nginx@sha256:8f335768880da6baf72b70c701002b45f4932acae8d574dedfddaf967fc3ac90
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Thu, 05 Aug 2021 21:49:59 +0800
    Ready:          True
    Restart Count:  0
    Environment:    
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-t8ktx (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-t8ktx:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  4m4s   default-scheduler  Successfully assigned dev/nginx to k8s-node-01
  Normal  Pulling    4m3s   kubelet            Pulling image "nginx"
  Normal  Pulled     3m45s  kubelet            Successfully pulled image "nginx" in 18.621044507s
  Normal  Created    3m45s  kubelet            Created container nginx
  Normal  Started    3m45s  kubelet            Started container nginx

# 获取podIP
[root@k8s-master-01 ~]# kubectl get pods -n dev -o wide
NAME    READY   STATUS    RESTARTS   AGE   IP           NODE          NOMINATED NODE   READINESS GATES
nginx   1/1     Running   0          10m   10.244.1.5   k8s-node-01              

# 访问POD
[root@k8s-master-01 ~]# curl 10.244.1.5:80
<!DOCTYPE html>


Welcome to nginx<span class="token operator">!</span><<span class="token operator">/</span>title>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<span class="token comment"># 删除指定Pod</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete pod nginx -n dev</span>
pod <span class="token string">"nginx"</span> deleted

<span class="token comment"># 稍等片刻,再查询Pod,发现Pod被删除了</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pods -n dev</span>
No resources found in dev namespace<span class="token punctuation">.</span>

<span class="token comment"># 注意: 如果当前Pod是由Pod控制器创建的,控制器会监控Pod状况,一旦发现Pod死亡,会立即重建</span>
<span class="token comment"># 此时要想删除Pod,必须删除Pod控制器</span>
</code></pre> 
  <blockquote> 
   <p><strong>配置操作</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个pod-nginx.yaml</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># vim pod-nginx.yaml</span>
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  namespace: dev
spec:
  containers:
    <span class="token operator">-</span> image: nginx
      name: pod
      ports:
        <span class="token operator">-</span> name: nginx<span class="token operator">-</span>port
          containerPort: 80
          protocol: TCP


<span class="token comment"># 然后就可以执行对应的创建和删除命令了:</span>
<span class="token comment"># 创建:</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl create -f pod-nginx.yaml </span>
pod<span class="token operator">/</span>nginx created

<span class="token comment"># 删除:</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete -f pod-nginx.yaml </span>
pod <span class="token string">"nginx"</span> deleted
</code></pre> 
  <h2>Label</h2> 
  <blockquote> 
   <p>Label是kubernetes系统中的一个重要概念。它的作用就是在资源上添加标识,用来对它们进行区分和选择。</p> 
   <p>Label的特点:</p> 
   <ul> 
    <li>一个Label会以key/value键值对的形式附加到各种对象上,如Node、Pod、Service等等</li> 
    <li>一个资源对象可以定义任意数量的Label ,同一个Label也可以被添加到任意数量的资源对象上去</li> 
    <li>Label通常在资源对象定义时确定,当然也可以在对象创建后动态添加或者删除</li> 
   </ul> 
  </blockquote> 
  <blockquote> 
   <p>可以通过Label实现资源的多维度分组,以便灵活、方便地进行资源分配、调度、配置、部署等管理工作。<br> 一些常用的Label 示例如下:</p> 
   <pre><code>版本标签:"version":"release", "version":"stable"......

环境标签:"environment":"dev","environment":"test","environment":"pro"

架构标签:"tier":"frontend","tier":"backend"
</code></pre> 
  </blockquote> 
  <blockquote> 
   <p>标签定义完毕之后,还要考虑到标签的选择,这就要使用到<strong>Label Selector</strong>,即:</p> 
   <pre><code>Label用于给某个资源对象定义标识

Label Selector用于查询和筛选拥有某些标签的资源对象
</code></pre> 
   <p>当前有两种<strong>Label Selector</strong>:</p> 
   <pre><code>基于等式的Label Selector   
name = slave: 选择所有包含Label中key="name"且value="slave"的对象   
env != production: 选择所有包括Label中的key="env"且value不等于"production"的对象

基于集合的Label Selector
name in (master, slave): 选择所有包含Label中的key="name"且value="master"或"slave"的对象
name not in (frontend): 选择所有包含Label中的key="name"且value不等于"frontend"的对象
</code></pre> 
   <p>标签的选择条件可以使用多个,此时将多个Label Selector进行组合,使用逗号 “,” 进行分隔即可。例如:</p> 
   <pre><code>name=slave,env!=production

name not in (frontend),env!=production
</code></pre> 
  </blockquote> 
  <blockquote> 
   <h3>Label资源的具体操作</h3> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建名称空间</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl create ns dev</span>
namespace<span class="token operator">/</span>dev created

<span class="token comment"># 创建一个pod节点,不指定pod控制器</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl run nginx --image=nginx --port=80 --namespace dev	 </span>
pod<span class="token operator">/</span>nginx created

<span class="token comment"># 为pod资源打标签</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl label pod nginx version=1.0 -n dev</span>
pod<span class="token operator">/</span>nginx labeled

<span class="token comment"># 为pod资源更新标签</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl label pod nginx version=2.0 -n dev --overwrite</span>
pod<span class="token operator">/</span>nginx labeled

<span class="token comment"># 查看标签</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pod nginx -n dev --show-labels</span>
NAME    READY   STATUS    RESTARTS   AGE   LABELS
nginx   1<span class="token operator">/</span>1     Running   0          12m   run=nginx<span class="token punctuation">,</span>version=2<span class="token punctuation">.</span>0

<span class="token comment"># 筛选标签</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pod -n dev -l version=2.0 --show-labels</span>
NAME    READY   STATUS    RESTARTS   AGE   LABELS
nginx   1<span class="token operator">/</span>1     Running   0          12m   run=nginx<span class="token punctuation">,</span>version=2<span class="token punctuation">.</span>0

<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pod -n dev -l version!=2.0 --show-labels</span>
No resources found in dev namespace<span class="token punctuation">.</span>

<span class="token comment"># 删除标签</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl label pod nginx version- -n dev</span>
pod<span class="token operator">/</span>nginx labeled
</code></pre> 
  <blockquote> 
   <p><strong>配置操作</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个pod-nginx.yaml</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># vim pod-nginx.yaml</span>
apiVersion: v1		<span class="token comment"># 版本号</span>
kind: Pod			<span class="token comment"># Pod资源</span>
metadata:			<span class="token comment"># Pod资源的元数据</span>
  name: nginx			<span class="token comment"># Pod资源的名字</span>
  namespace: dev		<span class="token comment"># Pod资源的名称空间	</span>
  labels:			<span class="token comment"># 模板定义的标签	</span>
    version: <span class="token string">"3.0"</span> 		<span class="token comment"># 标签1:版本</span>
    env: <span class="token string">"test"</span>		<span class="token comment"># 标签2:环境</span>
spec:			<span class="token comment"># 详细定义 </span>
  containers:		<span class="token comment"># 模板的容器</span>
  <span class="token operator">-</span> image: nginx:1<span class="token punctuation">.</span>17<span class="token punctuation">.</span>1		<span class="token comment"># 镜像版本</span>
    name: pod		<span class="token comment"># 容器的名称</span>
    ports:		<span class="token comment"># 容器的端口</span>
    <span class="token operator">-</span> name: nginx<span class="token operator">-</span>port		<span class="token comment"># 容器的端口名称</span>
      containerPort: 80		<span class="token comment"># 容器端口号</span>
      protocol: TCP		<span class="token comment"># 容器使用的协议</span>

<span class="token comment"># 然后就可以执行对应的更新命令了: kubectl apply -f pod-nginx.yaml</span>
</code></pre> 
  <h2>Deployment</h2> 
  <blockquote> 
   <ul> 
    <li> <p>在kubernetes中,Pod是最小的控制单元,但是kubernetes很少直接控制Pod,一般都是通过Pod控制器来完成的。Pod控制器用于pod的管理,确保pod资源符合预期的状态,当pod的资源出现故障时,会尝试进行重启或重建pod。</p> </li> 
    <li> <p>在kubernetes中Pod控制器的种类有很多,本章节只介绍一种:Deployment。<br> <a href="http://img.e-com-net.com/image/info8/47d121ebec454c70bafc9e3bc73897b1.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/47d121ebec454c70bafc9e3bc73897b1.jpg" alt="kubernetes 五种核心资源对象简介_第3张图片" width="650" height="355" style="border:1px solid black;"></a></p> </li> 
   </ul> 
  </blockquote> 
  <blockquote> 
   <h3>Deployment资源的具体操作</h3> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个pod</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl create -f deploy-nginx.yml </span>
deployment<span class="token punctuation">.</span>apps<span class="token operator">/</span>nginx created

<span class="token comment"># 查看创建的Pod</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pods -n dev</span>
NAME                     READY   STATUS    RESTARTS   AGE
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>lnsjx   1<span class="token operator">/</span>1     Running   0          62s
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>lvw6d   1<span class="token operator">/</span>1     Running   0          62s
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>qmgxt   1<span class="token operator">/</span>1     Running   0          62s

<span class="token comment"># 查看deployment的信息</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get deploy -n dev</span>
NAME    READY   UP<span class="token operator">-</span>TO<span class="token operator">-</span>DATE   AVAILABLE   AGE
nginx   3<span class="token operator">/</span>3     3            3           77s

<span class="token comment"># UP-TO-DATE:成功升级的副本数量</span>
<span class="token comment"># AVAILABLE:可用副本的数量</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get deploy -n dev -o wide</span>
NAME    READY   UP<span class="token operator">-</span>TO<span class="token operator">-</span>DATE   AVAILABLE   AGE    CONTAINERS   IMAGES   SELECTOR
nginx   3<span class="token operator">/</span>3     3            3           108s   nginx        nginx    run=nginx

<span class="token comment"># 查看deployment的详细信息</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl describe deploy nginx -n dev</span>
Name:                   nginx
Namespace:              dev
CreationTimestamp:      Fri<span class="token punctuation">,</span> 06 Aug 2021 19:47:57 <span class="token operator">+</span>0800
Labels:                 <none>
Annotations:            deployment<span class="token punctuation">.</span>kubernetes<span class="token punctuation">.</span>io<span class="token operator">/</span>revision: 1
Selector:               run=nginx
Replicas:               3 desired <span class="token punctuation">|</span> 3 updated <span class="token punctuation">|</span> 3 total <span class="token punctuation">|</span> 3 available <span class="token punctuation">|</span> 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25<span class="token operator">%</span> max unavailable<span class="token punctuation">,</span> 25<span class="token operator">%</span> max surge
Pod Template:
  Labels:  run=nginx
  Containers:
   nginx:
    Image:        nginx
    Port:         80<span class="token operator">/</span>TCP
    Host Port:    0<span class="token operator">/</span>TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  <span class="token function">Type</span>           Status  Reason
  <span class="token operator">--</span>-<span class="token operator">-</span>           <span class="token operator">--</span>-<span class="token operator">--</span><span class="token operator">-</span>  <span class="token operator">--</span>-<span class="token operator">--</span><span class="token operator">-</span>
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   nginx<span class="token operator">-</span>658f4cf99f <span class="token punctuation">(</span>3<span class="token operator">/</span>3 replicas created<span class="token punctuation">)</span>
Events:
  <span class="token function">Type</span>    Reason             Age    <span class="token keyword">From</span>                   Message
  <span class="token operator">--</span>-<span class="token operator">-</span>    <span class="token operator">--</span>-<span class="token operator">--</span><span class="token operator">-</span>             <span class="token operator">--</span>-<span class="token operator">-</span>   <span class="token operator">--</span>-<span class="token operator">-</span>                   <span class="token operator">--</span>-<span class="token operator">--</span>-<span class="token operator">-</span>
  Normal  ScalingReplicaSet  2m24s  deployment<span class="token operator">-</span>controller  Scaled up replica <span class="token function">set</span> nginx<span class="token operator">-</span>658f4cf99f to 3

<span class="token comment"># 删除 </span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete deploy nginx -n dev</span>
deployment<span class="token punctuation">.</span>apps <span class="token string">"nginx"</span> deleted
</code></pre> 
  <blockquote> 
   <p><strong>配置操作</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个deploy-nginx.yml</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># vim deploy-nginx.yml</span>
apiVersion: apps<span class="token operator">/</span>v1
kind: Deployment
metadata:
  name: nginx
  namespace: dev
spec:
  replicas: 3
  selector:
    matchLabels:
      run: nginx
  template:
    metadata:
      labels:
        run: nginx
    spec:
      containers:
        <span class="token operator">-</span> image: nginx
          name: nginx
          ports:
            <span class="token operator">-</span> containerPort: 80
              protocol: TCP

<span class="token comment"># 然后就可以执行对应的创建和删除命令了:</span>
<span class="token comment">#    创建:kubectl create -f deploy-nginx.yml</span>
<span class="token comment">#    删除:kubectl delete -f deploy-nginx.yml</span>
</code></pre> 
  <blockquote> 
   <p><strong>测试高可用</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 查看pod节点的ip地址</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pods -n dev -o wide</span>
NAME                     READY   STATUS    RESTARTS   AGE   IP           NODE          NOMINATED NODE   READINESS GATES
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>45zxh   1<span class="token operator">/</span>1     Running   0          56s   10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>2<span class="token punctuation">.</span>6   k8s<span class="token operator">-</span>node<span class="token operator">-</span>02   <none>           <none>
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>7wl4t   1<span class="token operator">/</span>1     Running   0          56s   10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>1<span class="token punctuation">.</span>3   k8s<span class="token operator">-</span>node<span class="token operator">-</span>01   <none>           <none>
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>xdhb4   1<span class="token operator">/</span>1     Running   0          56s   10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>1<span class="token punctuation">.</span>4   k8s<span class="token operator">-</span>node<span class="token operator">-</span>01   <none>           <none>

<span class="token comment"># 访问测试</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># curl 10.244.2.6:80</span>
<<span class="token operator">!</span>DOCTYPE html>
<html>
<head>
<title>Welcome to nginx<span class="token operator">!</span><<span class="token operator">/</span>title>
<style>
    body <span class="token punctuation">{</span>
        width: 35em<span class="token punctuation">;</span>
        margin: 0 auto<span class="token punctuation">;</span>
        font<span class="token operator">-</span>family: Tahoma<span class="token punctuation">,</span> Verdana<span class="token punctuation">,</span> Arial<span class="token punctuation">,</span> sans<span class="token operator">-</span>serif<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<<span class="token operator">/</span>style>
<<span class="token operator">/</span>head>
<body>
<h1>Welcome to nginx<span class="token operator">!</span><<span class="token operator">/</span>h1>
<p><span class="token keyword">If</span> you see this page<span class="token punctuation">,</span> the nginx web server is successfully installed and
working<span class="token punctuation">.</span> Further configuration is required<span class="token punctuation">.</span><<span class="token operator">/</span>p>

<p><span class="token keyword">For</span> online documentation and support please refer to
<a href=<span class="token string">"http://nginx.org/"</span>>nginx<span class="token punctuation">.</span>org<<span class="token operator">/</span>a><span class="token punctuation">.</span><br<span class="token operator">/</span>>
Commercial support is available at
<a href=<span class="token string">"http://nginx.com/"</span>>nginx<span class="token punctuation">.</span>com<<span class="token operator">/</span>a><span class="token punctuation">.</span><<span class="token operator">/</span>p>

<p><em>Thank you <span class="token keyword">for</span> <span class="token keyword">using</span> nginx<span class="token punctuation">.</span><<span class="token operator">/</span>em><<span class="token operator">/</span>p>
<<span class="token operator">/</span>body>
<<span class="token operator">/</span>html>

<span class="token comment"># 删除一个pod节点</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete pod nginx-658f4cf99f-45zxh -n dev</span>
pod <span class="token string">"nginx-658f4cf99f-45zxh"</span> deleted

<span class="token comment"># 再次查看pod节点的ip地址,新创建的pod节点IP地址发生了变化</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get pods -n dev -o wide</span>
NAME                     READY   STATUS    RESTARTS   AGE     IP           NODE          NOMINATED NODE   READINESS GATES
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>7wl4t   1<span class="token operator">/</span>1     Running   0          9m58s   10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>1<span class="token punctuation">.</span>3   k8s<span class="token operator">-</span>node<span class="token operator">-</span>01   <none>           <none>
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>r2m5m   1<span class="token operator">/</span>1     Running   0          45s     10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>2<span class="token punctuation">.</span>7   k8s<span class="token operator">-</span>node<span class="token operator">-</span>02   <none>           <none>
nginx<span class="token operator">-</span>658f4cf99f<span class="token operator">-</span>xdhb4   1<span class="token operator">/</span>1     Running   0          9m58s   10<span class="token punctuation">.</span>244<span class="token punctuation">.</span>1<span class="token punctuation">.</span>4   k8s<span class="token operator">-</span>node<span class="token operator">-</span>01   <none>           <none>
</code></pre> 
  <h2>Service</h2> 
  <blockquote> 
   <p>上个小章节,已经能够利用Deployment来创建一组Pod来提供具有高可用性的服务。</p> 
   <p>虽然每个Pod都会分配一个单独的Pod IP,然而却存在如下两个问题:</p> 
   <pre><code>1. Pod IP 会随着Pod的重建产生变化

2. Pod IP 仅仅是集群内可见的虚拟IP,外部无法访问
</code></pre> 
   <p>这样对于访问这个服务带来了难度。因此,kubernetes设计了Service来解决这个问题。</p> 
  </blockquote> 
  <blockquote> 
   <p><strong>Service可以看作是一组同类Pod对外的访问接口</strong>。借助Service,应用可以方便地实现<strong>服务发现</strong>和<strong>负载均衡</strong>。<br> <a href="http://img.e-com-net.com/image/info8/a46bb46d47be4614843425c9f1f545e9.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/a46bb46d47be4614843425c9f1f545e9.jpg" alt="kubernetes 五种核心资源对象简介_第4张图片" width="650" height="301" style="border:1px solid black;"></a></p> 
  </blockquote> 
  <blockquote> 
   <h3>Service资源的具体操作</h3> 
  </blockquote> 
  <blockquote> 
   <p><strong>操作一:创建集群内部可访问的Service(ClusterIP)</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 暴露service ; ClusterIP类型只能在集群内部执行</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl expose deploy nginx --name=svc-nginx1 --type=ClusterIP --port=80 --target-port=80 -n dev</span>
service<span class="token operator">/</span>svc<span class="token operator">-</span>nginx1 exposed

<span class="token comment"># 查看service</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get svc -n dev -o wide</span>
NAME         <span class="token function">TYPE</span>        CLUSTER<span class="token operator">-</span>IP     EXTERNAL<span class="token operator">-</span>IP   PORT<span class="token punctuation">(</span>S<span class="token punctuation">)</span>   AGE   SELECTOR
svc<span class="token operator">-</span>nginx1   ClusterIP   10<span class="token punctuation">.</span>107<span class="token punctuation">.</span>40<span class="token punctuation">.</span>22   <none>        80<span class="token operator">/</span>TCP    55s   run=nginx

<span class="token comment"># 这里产生了一个CLUSTER-IP,这就是service的IP,在Service的生命周期中,这个地址是不会变动的</span>
<span class="token comment"># 可以通过这个IP访问当前service对应的POD</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># curl 10.107.40.22:80</span>
<<span class="token operator">!</span>DOCTYPE html>
<html>
<head>
<title>Welcome to nginx<span class="token operator">!</span><<span class="token operator">/</span>title>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
</code></pre> 
  <blockquote> 
   <p><strong>操作二:创建集群外部也可访问的Service(NodePort)</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 上面创建的Service的type类型为ClusterIP,这个ip地址只用集群内部可访问</span>
<span class="token comment"># 如果需要创建外部也可以访问的Service,需要修改type为NodePort</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl expose deploy nginx --name=svc-nginx2 --type=NodePort --port=80 --target-port=80 -n dev</span>
service<span class="token operator">/</span>svc<span class="token operator">-</span>nginx2 exposed

<span class="token comment"># 此时查看,会发现出现了NodePort类型的Service,而且有一对Port(80:30198/TCP)</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl get svc -n dev -o wide</span>
NAME         <span class="token function">TYPE</span>        CLUSTER<span class="token operator">-</span>IP     EXTERNAL<span class="token operator">-</span>IP   PORT<span class="token punctuation">(</span>S<span class="token punctuation">)</span>        AGE     SELECTOR
svc<span class="token operator">-</span>nginx1   ClusterIP   10<span class="token punctuation">.</span>107<span class="token punctuation">.</span>40<span class="token punctuation">.</span>22   <none>        80<span class="token operator">/</span>TCP         23m     run=nginx
svc<span class="token operator">-</span>nginx2   NodePort    10<span class="token punctuation">.</span>100<span class="token punctuation">.</span>89<span class="token punctuation">.</span>10   <none>        80:30198<span class="token operator">/</span>TCP   2m43s   run=nginx

<span class="token comment"># 接下来就可以通过集群外的主机访问 节点的主机IP:31928访问服务了</span>
<span class="token comment"># 例如在的电脑主机上通过浏览器访问下面的地址</span>
http:<span class="token operator">/</span><span class="token operator">/</span>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>15<span class="token punctuation">.</span>11:30198<span class="token operator">/</span>		

<span class="token comment"># 删除service</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete svc svc-nginx1 -n dev</span>
service <span class="token string">"svc-nginx1"</span> deleted

<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl delete svc svc-nginx2 -n dev</span>
service <span class="token string">"svc-nginx2"</span> deleted
</code></pre> 
  <blockquote> 
   <p><strong>配置方式</strong></p> 
  </blockquote> 
  <pre><code class="prism language-powershell"><span class="token comment"># 创建一个svc-nginx.yml</span>
<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># vim svc_nginx.yml</span>
apiVersion: v1
kind: Service
metadata:
  namespace: dev
  name: svc<span class="token operator">-</span>nginx
spec:
  clusterIP: 10<span class="token punctuation">.</span>10<span class="token punctuation">.</span>10<span class="token punctuation">.</span>123
  ports:
    <span class="token operator">-</span> port: 80
      protocol: TCP
      targetPort: 80
  selector:
    run: nginx
  <span class="token function">type</span>: ClusterIP

<span class="token namespace">[root@k8s-master-01 ~]</span><span class="token comment"># kubectl create -f svc_nginx.yml </span>
service<span class="token operator">/</span>svc<span class="token operator">-</span>nginx created

<span class="token comment"># 然后就可以执行对应的创建和删除命令了:</span>
<span class="token comment">#    创建:kubectl  create  -f  svc-nginx.yml</span>
<span class="token comment">#    删除:kubectl  delete  -f  svc-nginx.yml</span>
</code></pre> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1683213643732299776"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(kubernetes,kubernetes)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835448111909138432.htm"
                           title="react-intl——react国际化使用方案" target="_blank">react-intl——react国际化使用方案</a>
                        <span class="text-muted">苹果酱0567</span>
<a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95%E9%A2%98%E6%B1%87%E6%80%BB%E4%B8%8E%E8%A7%A3%E6%9E%90/1.htm">面试题汇总与解析</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E4%B8%AD%E9%97%B4%E4%BB%B6/1.htm">中间件</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a>
                        <div>国际化介绍i18n:internationalization国家化简称,首字母+首尾字母间隔的字母个数+尾字母,类似的还有k8s(Kubernetes)React-intl是React中最受欢迎的库。使用步骤安装#usenpmnpminstallreact-intl-D#useyarn项目入口文件配置//index.tsximportReactfrom"react";importReactDOMf</div>
                    </li>
                    <li><a href="/article/1835375621996376064.htm"
                           title="Kubernetes数据持久化" target="_blank">Kubernetes数据持久化</a>
                        <span class="text-muted">看清所苡看轻</span>
<a class="tag" taget="_blank" href="/search/kubernetes%28k8s%29/1.htm">kubernetes(k8s)</a><a class="tag" taget="_blank" href="/search/emptyDir/1.htm">emptyDir</a><a class="tag" taget="_blank" href="/search/HostPath/1.htm">HostPath</a><a class="tag" taget="_blank" href="/search/pv/1.htm">pv</a><a class="tag" taget="_blank" href="/search/pvc/1.htm">pvc</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>在k8s中,Volume(数据卷)存在明确的生命周期(与包含该数据卷的容器组(pod)相同)。因此Volume的生命周期比同一容器组(pod)中任意容器的生命周期要更长,不管容器重启了多少次,数据都被保留下来。当然,如果pod不存在了,数据卷自然退出了。此时,根据pod所使用的数据卷类型不同,数据可能随着数据卷的退出而删除,也可能被真正持久化,并在下次容器组重启时仍然可以使用。从根本上来说,一个数</div>
                    </li>
                    <li><a href="/article/1835361001260806144.htm"
                           title="Kubernetes部署MySQL数据持久化" target="_blank">Kubernetes部署MySQL数据持久化</a>
                        <span class="text-muted">沫殇-MS</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/MySQL%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">MySQL数据库</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>一、安装配置NFS服务端1、安装nfs-kernel-server:sudoapt-yinstallnfs-kernel-server2、服务端创建共享目录#列出所有可用块设备的信息lsblk#格式化磁盘sudomkfs-text4/dev/sdb#创建一个目录:sudomkdir-p/data/nfs/mysql#更改目录权限:sudochown-Rnobody:nogroup/data/nfs</div>
                    </li>
                    <li><a href="/article/1835354574077128704.htm"
                           title="Kubernetes的3种数据持久化方式" target="_blank">Kubernetes的3种数据持久化方式</a>
                        <span class="text-muted">Seal^_^</span>
<a class="tag" taget="_blank" href="/search/%E3%80%90%E4%BA%91%E5%8E%9F%E7%94%9F%E3%80%91%E5%AE%B9%E5%99%A8%E5%8C%96%E4%B8%8E%E7%BC%96%E6%8E%92%E6%8A%80%E6%9C%AF/1.htm">【云原生】容器化与编排技术</a><a class="tag" taget="_blank" href="/search/%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90/1.htm">持续集成</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/EmptyDir/1.htm">EmptyDir</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/HostPath/1.htm">HostPath</a>
                        <div>Kubernetes的3种数据持久化方式1.EmptyDir2.HostPath3.PersistentVolume(PV)TheBegin点点关注,收藏不迷路Kubernetes提供了几种数据持久化方式,以满足不同场景的需求:1.EmptyDir用途:临时数据存储,Pod内容器间共享。特点:生命周期与Pod相同,Pod删除时数据也删除。2.HostPath用途:访问宿主机特定文件或目录。特点:增</div>
                    </li>
                    <li><a href="/article/1835353689854930944.htm"
                           title="【Kubernetes】常见面试题汇总(十一)" target="_blank">【Kubernetes】常见面试题汇总(十一)</a>
                        <span class="text-muted">summer.335</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>目录33.简述Kubernetes外部如何访问集群内的服务?34.简述Kubernetesingress?35.简述Kubernetes镜像的下载策略?33.简述Kubernetes外部如何访问集群内的服务?(1)对于Kubernetes,集群外的客户端默认情况,无法通过Pod的IP地址或者Service的虚拟IP地址:虚拟端口号进行访问。(2)通常可以通过以下方式进行访问Kubernetes集群</div>
                    </li>
                    <li><a href="/article/1835351925957160960.htm"
                           title="k8s中Service暴露的种类以及用法" target="_blank">k8s中Service暴露的种类以及用法</a>
                        <span class="text-muted">听说唐僧不吃肉</span>
<a class="tag" taget="_blank" href="/search/K8S/1.htm">K8S</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>一、说明在Kubernetes中,有几种不同的方式可以将服务(Service)暴露给外部流量。这些方式通过定义服务的spec.type字段来确定。二、详解1.ClusterIP定义:默认类型,服务只能在集群内部访问。作用:通过集群内部IP地址暴露服务。示例:spec:type:ClusterIPports:-port:80targetPo</div>
                    </li>
                    <li><a href="/article/1835347257772306432.htm"
                           title="Kubernetes 自定义控制器开发" target="_blank">Kubernetes 自定义控制器开发</a>
                        <span class="text-muted">IT回忆录</span>
<a class="tag" taget="_blank" href="/search/Kubenetes/1.htm">Kubenetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>目录前言一、CRD二、创建数据库表(Mysql)二、控制器开发1.使用kubernetes的examplecontroller模板2.在controller.go中新增数据表监听方法3.修改tools工具生成资源对象结构体定义这里记录开发k8s控制器的一般方式,controller开发主要使用k8s提供的client-go库进行。前言Controller监听集群内部资源对象的变化,编辑资源对象(增</div>
                    </li>
                    <li><a href="/article/1835344356878413824.htm"
                           title="用kubedam搭建的k8s证书过期处理方法" target="_blank">用kubedam搭建的k8s证书过期处理方法</a>
                        <span class="text-muted">我滴鬼鬼呀wks</span>
<a class="tag" taget="_blank" href="/search/k8s/1.htm">k8s</a><a class="tag" taget="_blank" href="/search/1024%E7%A8%8B%E5%BA%8F%E5%91%98%E8%8A%82/1.htm">1024程序员节</a>
                        <div>kubeadm部署的k8s证书过期1、查看证书过期时间kubeadmalphacertscheck-expiration若证书已经过期无法试用kubectl命令建议修改服务器时间到未过期的时间段2、配置kube-controller-manager.yaml文件cat/etc/kubernetes/manifests/kube-controller-manager.yamlapiVersion:v</div>
                    </li>
                    <li><a href="/article/1835340955637608448.htm"
                           title="k8s证书过期问题处理" target="_blank">k8s证书过期问题处理</a>
                        <span class="text-muted">olina_qin</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>k8s证书过期问题处理opensslx509-in/etc/kubernetes/pki/apiserver.crt-noout-dateskubeadmcertsrenewallsystemctlrestartkubeleopensslx509-in/etc/kubernetes/pki/apiserver.crt-noout-text|grep"NotAfter"cp/etc/kubernet</div>
                    </li>
                    <li><a href="/article/1835337301350248448.htm"
                           title="Kubernetes Ingress 控制器(Nginx)安装与使用教程" target="_blank">Kubernetes Ingress 控制器(Nginx)安装与使用教程</a>
                        <span class="text-muted">农优影</span>

                        <div>KubernetesIngress控制器(Nginx)安装与使用教程kubernetes-ingressNGINXandNGINXPlusIngressControllersforKubernetes项目地址:https://gitcode.com/gh_mirrors/ku/kubernetes-ingress1.项目目录结构及介绍在nginxinc/kubernetes-ingress仓库中,</div>
                    </li>
                    <li><a href="/article/1835331377520799744.htm"
                           title="【K8s】专题十一:Kubernetes 集群证书过期处理方法" target="_blank">【K8s】专题十一:Kubernetes 集群证书过期处理方法</a>
                        <span class="text-muted">行者Sun1989</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>本文内容均来自个人笔记并重新梳理,如有错误欢迎指正!如果对您有帮助,烦请点赞、关注、转发、订阅专栏!专栏订阅入口Linux专栏|Docker专栏|Kubernetes专栏往期精彩文章【Docker】(全网首发)KylinV10下MySQL容器内存占用异常的解决方法【Docker】(全网首发)KylinV10下MySQL容器内存占用异常的解决方法(续)【Docker】MySQL源码构建Docker镜</div>
                    </li>
                    <li><a href="/article/1835269935358636032.htm"
                           title="Docker学习十一:Kubernetes概述" target="_blank">Docker学习十一:Kubernetes概述</a>
                        <span class="text-muted">爱打羽球的程序猿</span>
<a class="tag" taget="_blank" href="/search/Docker%E5%AD%A6%E4%B9%A0%E7%B3%BB%E5%88%97/1.htm">Docker学习系列</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a>
                        <div>一、Kubernetes简介2006年,Google提出了云计算的概念,当时的云计算领域还是以虚拟机为代表的云平台。2013年,Docker横空出世,Docker提出了镜像、仓库等核心概念,规范了服务的交付标准,使得复杂服务的落地变得更加简单,之后Docker又定义了OCI标准,Docker在容器领域称为事实的标准。但是,Docker诞生只是帮助定义了开发和交付标准,如果想要在生产环境中大批量的使</div>
                    </li>
                    <li><a href="/article/1835269304761806848.htm"
                           title="Cloud Native Weekly | 华为云抢先发布Redis5.0,红帽宣布收购混合云提供商" target="_blank">Cloud Native Weekly | 华为云抢先发布Redis5.0,红帽宣布收购混合云提供商</a>
                        <span class="text-muted">weixin_34302561</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/devops/1.htm">devops</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a>
                        <div>1——华为云抢先发布Redis5.02——DigitalOceanK8s服务正式上线3——红帽宣布收购混合云提供商NooBaa4——微软发布多项AzureKubernetes服务更新1华为云抢先发布Redis5.012月17日,华为云在DCS2.0的基础上,快人一步,抢先推出了新的Redis5.0产品,这是一个崭新的突破。目前国内在缓存领域的发展普遍停留在Redis4.0阶段,华为云率先发布了Re</div>
                    </li>
                    <li><a href="/article/1835209173944594432.htm"
                           title="(k8s)Kubernetes 从0到1容器编排之旅" target="_blank">(k8s)Kubernetes 从0到1容器编排之旅</a>
                        <span class="text-muted">道不贱卖,法不轻传</span>
<a class="tag" taget="_blank" href="/search/kubernets/1.htm">kubernets</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>一、引言在当今数字化的浪潮中,Kubernetes如同一艘强大的航船,引领着容器化应用的部署与管理。它以其卓越的灵活性、可扩展性和可靠性,成为众多企业和开发者的首选。然而,要真正发挥Kubernetes的强大威力,仅仅掌握基本操作是远远不够的。本文将带你深入探索Kubernetes使用过程中的奇技妙法,为你开启一段优雅的容器编排之旅。二、高级资源管理之精妙艺术1.资源配额与限制:雕琢资源之美•Ku</div>
                    </li>
                    <li><a href="/article/1835061888858288128.htm"
                           title="【K8S】kubernetes集群架构与组件" target="_blank">【K8S】kubernetes集群架构与组件</a>
                        <span class="text-muted">奇奇怪怪^</span>
<a class="tag" taget="_blank" href="/search/%E4%BA%91/1.htm">云</a><a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/IT/1.htm">IT</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                        <div>文章目录【K8S】kubernetes集群架构与组件kubernetes组件**master组件**node组件整体流程POD终止过程【K8S】kubernetes集群架构与组件kubernetes组件K8S是属于主从设备模型(Master-slave架构),即有Master节点负责集群的调度、管理和运维,Slave节点是集群中的运算工作负载节点在K8S中,主节点一般被称为Master节点,而从节</div>
                    </li>
                    <li><a href="/article/1835058988631289856.htm"
                           title="K8S学习笔记02——K8S组件" target="_blank">K8S学习笔记02——K8S组件</a>
                        <span class="text-muted">沉淅尘</span>
<a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Docker/1.htm">Docker</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/K8S/1.htm">K8S</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>Kubernetes组件一、控制平面组件(ControlPlaneComponents)(1)kube-apiserver(2)etcd(3)kube-scheduler(4)kube-controller-manager(5)cloud-controller-manager二、Node组件1.kubelet2.kube-proxy3.容器运行时(ContainerRuntime)三、插件(Add</div>
                    </li>
                    <li><a href="/article/1835054063679533056.htm"
                           title="Kubernetes——组件" target="_blank">Kubernetes——组件</a>
                        <span class="text-muted">窒息う</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a>
                        <div>文章目录K8S的优势核心架构角色与功能集群图例K8S的优势能管理大量跨主机容器快速部署应用快速扩展应用无缝对接新的应用节省资源,优化硬件资源的使用核心架构master(管理节点)node(计算节点)images(镜像节点)角色与功能Master功能提供集群的控制对集群进行全局决策检测和响应集群事件Master节点核心组件APIServer是整个系统的对外接口,提供客户端和其他组件调用后端元数据存储</div>
                    </li>
                    <li><a href="/article/1835046751275413504.htm"
                           title="Kubernetes组件" target="_blank">Kubernetes组件</a>
                        <span class="text-muted">汉只只</span>
<a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/%E5%88%86%E5%B8%83%E5%BC%8F/1.htm">分布式</a><a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a>
                        <div>Kubernetes核心组件Kubernetes定义了一组构建块,它们可以共同提供部署、维护和扩展应用程序的机制。组成Kubernetes的组件设计为松耦合和可扩展的,这样可以满足多种不同的工作负载。可扩展性在很大程度上由KubernetesAPI提供——它被作为扩展的内部组件以及Kubernetes上运行的容器等使用。Kubernetes主要由以下几个核心组件组成:etcd保存了整个集群的状态;</div>
                    </li>
                    <li><a href="/article/1835034781197365248.htm"
                           title="【Linux 从基础到进阶】Kubernetes 集群搭建与管理" target="_blank">【Linux 从基础到进阶】Kubernetes 集群搭建与管理</a>
                        <span class="text-muted">爱技术的小伙子</span>
<a class="tag" taget="_blank" href="/search/Linux%E4%BB%8E%E5%9F%BA%E7%A1%80%E5%88%B0%E8%BF%9B%E9%98%B6/1.htm">Linux从基础到进阶</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a>
                        <div>Kubernetes集群搭建与管理Kubernetes(简称K8s)是一个用于自动化部署、扩展和管理容器化应用程序的开源平台。它提供了容器编排功能,能够管理大量的容器实例,并支持应用的自动扩展、高可用性和自愈能力。本文将详细介绍如何在CentOS和Ubuntu系统上安装和配置Kubernetes集群,并讲解Kubernetes的基本概念和管理操作。1.Kubernetes基础概念在了解如何搭建Ku</div>
                    </li>
                    <li><a href="/article/1834999728476090368.htm"
                           title="【Kubernetes】常见面试题汇总(十三)" target="_blank">【Kubernetes】常见面试题汇总(十三)</a>
                        <span class="text-muted">summer.335</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>目录39.简述KubernetesScheduler使用哪两种算法将Pod绑定到worker节点?40.简述Kuberneteskubelet的作用?41.简述Kuberneteskubelet监控Worker节点资源是使用什么组件来实现的?39.简述KubernetesScheduler使用哪两种算法将Pod绑定到worker节点?KubernetesScheduler根据如下两种调度算法将Po</div>
                    </li>
                    <li><a href="/article/1834893444238110720.htm"
                           title="Ansible自动化部署kubernetes集群" target="_blank">Ansible自动化部署kubernetes集群</a>
                        <span class="text-muted">theo.wu</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/ansible/1.htm">ansible</a><a class="tag" taget="_blank" href="/search/%E8%87%AA%E5%8A%A8%E5%8C%96/1.htm">自动化</a>
                        <div>机器环境介绍1.1.机器信息介绍IPhostnameapplicationCPUMemory192.168.204.129k8s-master01etcd,kube-apiserver,kube-controller-manager,kube-scheduler,kubelet,kube-proxy,containerd2C4G192.168.204.130k8s-worker01etcd,kub</div>
                    </li>
                    <li><a href="/article/1834787055985586176.htm"
                           title="K8S - Emptydir - 取代ELK 使用fluentd 构建logging saidcar" target="_blank">K8S - Emptydir - 取代ELK 使用fluentd 构建logging saidcar</a>
                        <span class="text-muted">nvd11</span>
<a class="tag" taget="_blank" href="/search/K8S/1.htm">K8S</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>由于k8s的无状态service通常部署在多个POD中,实现多实例面向高并发。但是k8s本身并没有提供集中查询多个pod的日志的功能其中1个常见方案就是ELK.本文的方案是利用fluentdsidecar和emptydir把多个pod的日志导向到bigquery的table中。Emptydir的简介Kubernetes中的EmptyDir是一种用于容器之间共享临时存储的空目录卷类型。EmptyDi</div>
                    </li>
                    <li><a href="/article/1834610443310690304.htm"
                           title="kubernetes里面那些事————控制器" target="_blank">kubernetes里面那些事————控制器</a>
                        <span class="text-muted">背锅攻城师</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>资源-控制器一,控制器作用二,控制器类型2.1,Deployment:无状态应用部署2.2,DaemonSet:确保所有Node运行同一个pod2.3,StatefulSet:有状态应用部署2.4,Job:一次性任务2.5,CronJob:定时任务2.6,pod2.7,service2.8,replicaset2.9,endpoints三,控制器yaml应用3.1,Deployment3.2,Da</div>
                    </li>
                    <li><a href="/article/1834610316504297472.htm"
                           title="kubernetes里面那些事—————存储" target="_blank">kubernetes里面那些事—————存储</a>
                        <span class="text-muted">背锅攻城师</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>常用数据卷类型一,emptyDir1.1,emptyDir概念1.2,应用场景1.3,yaml示例二,hostPath2.1,hostPath概念2.2,应用场景2.3,yaml示例三,congfigmap3.1,configmap的作用3.2,注意事项:3.3,使用configmap创建java项目配置文件3.4,subPath应用3.5,configmap作为环境变量四,secret4.1,s</div>
                    </li>
                    <li><a href="/article/1834610316068089856.htm"
                           title="kubernetes-flannel组件的安装方式" target="_blank">kubernetes-flannel组件的安装方式</a>
                        <span class="text-muted">背锅攻城师</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>使用flannel网络数据转发的过程数据->源容器->宿主机docker0虚拟网卡->flannel0虚拟网卡(UDP封装->etcd->目标容器所在宿主机flannel0->目标容器所在宿主机的docker0虚拟网卡->目标容器文章目录二进制安装flannelyaml文件部署flannel二进制安装flannel一,原有的二进制etcd集群添加配置信息#[Member]ETCD_NAME="et</div>
                    </li>
                    <li><a href="/article/1834546926272475136.htm"
                           title="深入理解Kubernetes:kube-scheduler源码解析" target="_blank">深入理解Kubernetes:kube-scheduler源码解析</a>
                        <span class="text-muted">mujingluo</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>Kubernetes的调度器(kube-scheduler)是整个系统中至关重要的组件,它负责将待调度的Pods分配到合适的节点上。本文将深入分析kube-scheduler的源码,揭示其内部工作机制。kube-scheduler的核心功能kube-scheduler的核心功能包括:监听Pod变化:通过KubernetesAPI监听所有未调度的Pods。过滤(Filtering):根据一系列规则(</div>
                    </li>
                    <li><a href="/article/1834543901835358208.htm"
                           title="开源项目 Kubernetes 源码探索与部署指南" target="_blank">开源项目 Kubernetes 源码探索与部署指南</a>
                        <span class="text-muted">邹滢朦</span>

                        <div>开源项目Kubernetes源码探索与部署指南kubernetesThisistherepothattracksallpatchestotheOpenShiftdistributionofKubernetesonbranchescorrespondingtoOpenShiftreleases.Seehttps://github.com/openshift/kubernetes/blob/maste</div>
                    </li>
                    <li><a href="/article/1834522729504665600.htm"
                           title="【2023年】云计算金砖牛刀小试4" target="_blank">【2023年】云计算金砖牛刀小试4</a>
                        <span class="text-muted">geekgold</span>
<a class="tag" taget="_blank" href="/search/%E4%BA%91%E8%AE%A1%E7%AE%97/1.htm">云计算</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/jenkins/1.htm">jenkins</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a>
                        <div>容器云问题1.Kubernetes集群支持Pod优先级抢占,通过抢占式调度策略来实现同一个Node节点内部的Pod对象抢占。在master节点/root目录下编写YAML文件schedule.yaml创建一个抢占式调度策略,具体要求如下:(1)抢占式调度策略名称:high-scheduling;(2)优先级为1000000;(3)不要将该调度策略设置为默认优先调度策略。vischedule.yam</div>
                    </li>
                    <li><a href="/article/1834471045063602176.htm"
                           title="【Kubernetes】(K8S)彻底卸载详细教程" target="_blank">【Kubernetes】(K8S)彻底卸载详细教程</a>
                        <span class="text-muted">哒哒-blog</span>
<a class="tag" taget="_blank" href="/search/Kubernetes/1.htm">Kubernetes</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a>
                        <div>以下全部操作都是使用root用户进行(非root用户可以使用sudo),并且全部命令都需要在Kubernetes集群的所有节点分别执行:第一步、停止K8S所有节点执行:123systemctlstopkubeletsystemctlstopetcdsystemctlstopdocker第二步、清空K8S集群设置所有节点执行:1kubeadmreset-f第三步、删除K8S相关软件所有节点执行:12</div>
                    </li>
                    <li><a href="/article/1834467134424576000.htm"
                           title="二进制方式部署K8s高可用集群" target="_blank">二进制方式部署K8s高可用集群</a>
                        <span class="text-muted">麻辣头马头</span>
<a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a>
                        <div>1二进制方式部署K8s高可用集群1.1kubeadm和二进制安装k8s适用场景分析kubeadm是官方提供的开源工具,是一个开源项目,用于快速搭建kubernetes集群,目前是比较方便和推荐使用的。kubeadminit以及kubeadmjoin这两个命令可以快速创建kubernetes集群。Kubeadm初始化k8s,所有的组件都是以pod形式运行的,具备故障自恢复能力。kubeadm是工具,</div>
                    </li>
                                <li><a href="/article/68.htm"
                                       title="mongodb3.03开启认证" target="_blank">mongodb3.03开启认证</a>
                                    <span class="text-muted">21jhf</span>
<a class="tag" taget="_blank" href="/search/mongodb/1.htm">mongodb</a>
                                    <div>下载了最新mongodb3.03版本,当使用--auth 参数命令行开启mongodb用户认证时遇到很多问题,现总结如下: 
(百度上搜到的基本都是老版本的,看到db.addUser的就是,请忽略) 
Windows下我做了一个bat文件,用来启动mongodb,命令行如下: 
mongod --dbpath db\data --port 27017 --directoryperdb --logp</div>
                                </li>
                                <li><a href="/article/195.htm"
                                       title="【Spark103】Task not serializable" target="_blank">【Spark103】Task not serializable</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/Serializable/1.htm">Serializable</a>
                                    <div>Task not serializable是Spark开发过程最令人头疼的问题之一,这里记录下出现这个问题的两个实例,一个是自己遇到的,另一个是stackoverflow上看到。等有时间了再仔细探究出现Task not serialiazable的各种原因以及出现问题后如何快速定位问题的所在,至少目前阶段碰到此类问题,没有什么章法 
1. 
  
package spark.exampl</div>
                                </li>
                                <li><a href="/article/322.htm"
                                       title="你所熟知的 LRU(最近最少使用)" target="_blank">你所熟知的 LRU(最近最少使用)</a>
                                    <span class="text-muted">dalan_123</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>关于LRU这个名词在很多地方或听说,或使用,接下来看下lru缓存回收的实现 
1、大体的想法 
    a、查询出最近最晚使用的项 
    b、给最近的使用的项做标记 
通过使用链表就可以完成这两个操作,关于最近最少使用的项只需要返回链表的尾部;标记最近使用的项,只需要将该项移除并放置到头部,那么难点就出现 你如何能够快速在链表定位对应的该项? 
这时候多</div>
                                </li>
                                <li><a href="/article/449.htm"
                                       title="Javascript 跨域" target="_blank">Javascript 跨域</a>
                                    <span class="text-muted">周凡杨</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/jsonp/1.htm">jsonp</a><a class="tag" taget="_blank" href="/search/%E8%B7%A8%E5%9F%9F/1.htm">跨域</a><a class="tag" taget="_blank" href="/search/cross-domain/1.htm">cross-domain</a>
                                    <div>  
                                 </div>
                                </li>
                                <li><a href="/article/576.htm"
                                       title="linux下安装apache服务器" target="_blank">linux下安装apache服务器</a>
                                    <span class="text-muted">g21121</span>
<a class="tag" taget="_blank" href="/search/apache/1.htm">apache</a>
                                    <div>安装apache  
下载windows版本apache,下载地址:http://httpd.apache.org/download.cgi 
   1.windows下安装apache   
Windows下安装apache比较简单,注意选择路径和端口即可,这里就不再赘述了。  2.linux下安装apache:  
下载之后上传到linux的相关目录,这里指定为/home/apach</div>
                                </li>
                                <li><a href="/article/703.htm"
                                       title="FineReport的JS编辑框和URL地址栏语法简介" target="_blank">FineReport的JS编辑框和URL地址栏语法简介</a>
                                    <span class="text-muted">老A不折腾</span>
<a class="tag" taget="_blank" href="/search/finereport/1.htm">finereport</a><a class="tag" taget="_blank" href="/search/web%E6%8A%A5%E8%A1%A8/1.htm">web报表</a><a class="tag" taget="_blank" href="/search/%E6%8A%A5%E8%A1%A8%E8%BD%AF%E4%BB%B6/1.htm">报表软件</a><a class="tag" taget="_blank" href="/search/%E8%AF%AD%E6%B3%95%E6%80%BB%E7%BB%93/1.htm">语法总结</a>
                                    <div>  JS编辑框: 
1.FineReport的js。 
作为一款BS产品,browser端的JavaScript是必不可少的。 
FineReport中的js是已经调用了finereport.js的。 
大家知道,预览报表时,报表servlet会将cpt模板转为html,在这个html的head头部中会引入FineReport的js,这个finereport.js中包含了许多内置的fun</div>
                                </li>
                                <li><a href="/article/830.htm"
                                       title="根据STATUS信息对MySQL进行优化" target="_blank">根据STATUS信息对MySQL进行优化</a>
                                    <span class="text-muted">墙头上一根草</span>
<a class="tag" taget="_blank" href="/search/status/1.htm">status</a>
                                    <div>mysql  查看当前正在执行的操作,即正在执行的sql语句的方法为: 
     show processlist 命令 
  
mysql> show global status;可以列出MySQL服务器运行各种状态值,我个人较喜欢的用法是show status like '查询值%';一、慢查询mysql> show variab</div>
                                </li>
                                <li><a href="/article/957.htm"
                                       title="我的spring学习笔记7-Spring的Bean配置文件给Bean定义别名" target="_blank">我的spring学习笔记7-Spring的Bean配置文件给Bean定义别名</a>
                                    <span class="text-muted">aijuans</span>
<a class="tag" taget="_blank" href="/search/Spring+3/1.htm">Spring 3</a>
                                    <div>本文介绍如何给Spring的Bean配置文件的Bean定义别名? 
 
原始的 
 
 
<bean id="business" class="onlyfun.caterpillar.device.Business">
    <property name="writer">
        <ref b</div>
                                </li>
                                <li><a href="/article/1084.htm"
                                       title="高性能mysql 之 性能剖析" target="_blank">高性能mysql 之 性能剖析</a>
                                    <span class="text-muted">annan211</span>
<a class="tag" taget="_blank" href="/search/%E6%80%A7%E8%83%BD/1.htm">性能</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/mysql+%E6%80%A7%E8%83%BD%E5%89%96%E6%9E%90/1.htm">mysql 性能剖析</a><a class="tag" taget="_blank" href="/search/%E5%89%96%E6%9E%90/1.htm">剖析</a>
                                    <div>

1 定义性能优化
  mysql服务器性能,此处定义为 响应时间。
  在解释性能优化之前,先来消除一个误解,很多人认为,性能优化就是降低cpu的利用率或者减少对资源的使用。
  这是一个陷阱。
  资源时用来消耗并用来工作的,所以有时候消耗更多的资源能够加快查询速度,保持cpu忙绿,这是必要的。很多时候发现
  编译进了新版本的InnoDB之后,cpu利用率上升的很厉害,这并不</div>
                                </li>
                                <li><a href="/article/1211.htm"
                                       title="主外键和索引唯一性约束" target="_blank">主外键和索引唯一性约束</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/%E7%B4%A2%E5%BC%95/1.htm">索引</a><a class="tag" taget="_blank" href="/search/%E5%94%AF%E4%B8%80%E6%80%A7%E7%BA%A6%E6%9D%9F/1.htm">唯一性约束</a><a class="tag" taget="_blank" href="/search/%E4%B8%BB%E5%A4%96%E9%94%AE%E7%BA%A6%E6%9D%9F/1.htm">主外键约束</a><a class="tag" taget="_blank" href="/search/%E8%81%94%E6%9C%BA%E5%88%A0%E9%99%A4/1.htm">联机删除</a>
                                    <div>目标;第一步;创建两张表 用户表和文章表 
        第二步;发表文章 
  
  
  1,建表; 
    ---用户表 BlogUsers
    --userID唯一的
    --userName
    --pwd
    --sex
        

    create </div>
                                </li>
                                <li><a href="/article/1338.htm"
                                       title="线程的调度" target="_blank">线程的调度</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">多线程</a><a class="tag" taget="_blank" href="/search/thread/1.htm">thread</a><a class="tag" taget="_blank" href="/search/%E7%BA%BF%E7%A8%8B%E7%9A%84%E8%B0%83%E5%BA%A6/1.htm">线程的调度</a><a class="tag" taget="_blank" href="/search/java%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">java多线程</a>
                                    <div>1.       Java提供一个线程调度程序来监控程序中启动后进入可运行状态的所有线程。线程调度程序按照线程的优先级决定应调度哪些线程来执行。 
  
2.       多数线程的调度是抢占式的(即我想中断程序运行就中断,不需要和将被中断的程序协商) 
a) </div>
                                </li>
                                <li><a href="/article/1465.htm"
                                       title="查看日志常用命令" target="_blank">查看日志常用命令</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E5%91%BD%E4%BB%A4/1.htm">命令</a><a class="tag" taget="_blank" href="/search/unix/1.htm">unix</a>
                                    <div>一.日志查找方法,可以用通配符查某台主机上的所有服务器grep "关键字" /wls/applogs/custom-*/error.log 
  
二.查看日志常用命令1.grep '关键字' error.log:在error.log中搜索'关键字'2.grep -C10 '关键字' error.log:显示关键字前后10行记录3.grep '关键字' error.l</div>
                                </li>
                                <li><a href="/article/1592.htm"
                                       title="【持久化框架MyBatis3一】MyBatis版HelloWorld" target="_blank">【持久化框架MyBatis3一】MyBatis版HelloWorld</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/helloworld/1.htm">helloworld</a>
                                    <div>MyBatis这个系列的文章,主要参考《Java Persistence with MyBatis 3》。 
  样例数据 
本文以MySQL数据库为例,建立一个STUDENTS表,插入两条数据,然后进行单表的增删改查 
  
  
CREATE TABLE STUDENTS
(
stud_id int(11) NOT NULL AUTO_INCREMENT,
</div>
                                </li>
                                <li><a href="/article/1719.htm"
                                       title="【Hadoop十五】Hadoop Counter" target="_blank">【Hadoop十五】Hadoop Counter</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a>
                                    <div>  
 1. 只有Map任务的Map Reduce Job  
	File System Counters
		FILE: Number of bytes read=3629530
		FILE: Number of bytes written=98312
		FILE: Number of read operations=0
		FILE: Number of lar</div>
                                </li>
                                <li><a href="/article/1846.htm"
                                       title="解决Tomcat数据连接池无法释放" target="_blank">解决Tomcat数据连接池无法释放</a>
                                    <span class="text-muted">ronin47</span>
<a class="tag" taget="_blank" href="/search/tomcat+%E8%BF%9E%E6%8E%A5%E6%B1%A0%E3%80%80%E4%BC%98%E5%8C%96/1.htm">tomcat 连接池 优化</a>
                                    <div> 
 近段时间,公司的检测中心报表系统(SMC)的开发人员时不时找到我,说用户老是出现无法登录的情况。前些日子因为手头上 有Jboss集群的测试工作,发现用户不能登录时,都是在Tomcat中将这个项目Reload一下就好了,不过只是治标而已,因为大概几个小时之后又会 再次出现无法登录的情况。 
  
今天上午,开发人员小毛又找到我,要我协助将这个问题根治一下,拖太久用户难保不投诉。 
简单分析了一</div>
                                </li>
                                <li><a href="/article/1973.htm"
                                       title="java-75-二叉树两结点的最低共同父结点" target="_blank">java-75-二叉树两结点的最低共同父结点</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>
import java.util.LinkedList;
import java.util.List;

import ljn.help.*;
public class BTreeLowestParentOfTwoNodes {

	public static void main(String[] args) {
		/*
		 * node data is stored in</div>
                                </li>
                                <li><a href="/article/2100.htm"
                                       title="行业垂直搜索引擎网页抓取项目" target="_blank">行业垂直搜索引擎网页抓取项目</a>
                                    <span class="text-muted">carlwu</span>
<a class="tag" taget="_blank" href="/search/Lucene/1.htm">Lucene</a><a class="tag" taget="_blank" href="/search/Nutch/1.htm">Nutch</a><a class="tag" taget="_blank" href="/search/Heritrix/1.htm">Heritrix</a><a class="tag" taget="_blank" href="/search/Solr/1.htm">Solr</a>
                                    <div>公司有一个搜索引擎项目,希望各路高人有空来帮忙指导,谢谢! 
这是详细需求: 
(1) 通过提供的网站地址(大概100-200个网站),网页抓取程序能不断抓取网页和其它类型的文件(如Excel、PDF、Word、ppt及zip类型),并且程序能够根据事先提供的规则,过滤掉不相干的下载内容。 
(2) 程序能够搜索这些抓取的内容,并能对这些抓取文件按照油田名进行分类,然后放到服务器不同的目录中。 
</div>
                                </li>
                                <li><a href="/article/2227.htm"
                                       title="[通讯与服务]在总带宽资源没有大幅增加之前,不适宜大幅度降低资费" target="_blank">[通讯与服务]在总带宽资源没有大幅增加之前,不适宜大幅度降低资费</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/%E8%B5%84%E6%BA%90/1.htm">资源</a>
                                    <div> 
 
      降低通讯服务资费,就意味着有更多的用户进入,就意味着通讯服务提供商要接待和服务更多的用户,在总体运维成本没有由于技术升级而大幅下降的情况下,这种降低资费的行为将导致每个用户的平均带宽不断下降,而享受到的服务质量也在下降,这对用户和服务商都是不利的。。。。。。。。 
 
 
    &nbs</div>
                                </li>
                                <li><a href="/article/2354.htm"
                                       title="Java时区转换及时间格式" target="_blank">Java时区转换及时间格式</a>
                                    <span class="text-muted">Cwind</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>本文介绍Java API 中 Date, Calendar, TimeZone和DateFormat的使用,以及不同时区时间相互转化的方法和原理。 
  
问题描述: 
向处于不同时区的服务器发请求时需要考虑时区转换的问题。譬如,服务器位于东八区(北京时间,GMT+8:00),而身处东四区的用户想要查询当天的销售记录。则需把东四区的“今天”这个时间范围转换为服务器所在时区的时间范围。 
</div>
                                </li>
                                <li><a href="/article/2481.htm"
                                       title="readonly,只读,不可用" target="_blank">readonly,只读,不可用</a>
                                    <span class="text-muted">dashuaifu</span>
<a class="tag" taget="_blank" href="/search/js/1.htm">js</a><a class="tag" taget="_blank" href="/search/jsp/1.htm">jsp</a><a class="tag" taget="_blank" href="/search/disable/1.htm">disable</a><a class="tag" taget="_blank" href="/search/readOnly/1.htm">readOnly</a><a class="tag" taget="_blank" href="/search/readOnly/1.htm">readOnly</a>
                                    <div>readOnly 和 readonly 不同,在做js开发时一定要注意函数大小写和jsp黄线的警告!!!我就经历过这么一件事: 
使用readOnly在某些浏览器或同一浏览器不同版本有的可以实现“只读”功能,有的就不行,而且函数readOnly有黄线警告!!!就这样被折磨了不短时间!!!(期间使用过disable函数,但是发现disable函数之后后台接收不到前台的的数据!!!) 
  </div>
                                </li>
                                <li><a href="/article/2608.htm"
                                       title="LABjs、RequireJS、SeaJS 介绍" target="_blank">LABjs、RequireJS、SeaJS 介绍</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/js/1.htm">js</a><a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a>
                                    <div>LABjs 的核心是 LAB(Loading and Blocking):Loading 指异步并行加载,Blocking 是指同步等待执行。LABjs 通过优雅的语法(script 和 wait)实现了这两大特性,核心价值是性能优化。LABjs 是一个文件加载器。RequireJS 和 SeaJS 则是模块加载器,倡导的是一种模块化开发理念,核心价值是让 JavaScript 的模块化开发变得更</div>
                                </li>
                                <li><a href="/article/2735.htm"
                                       title="[应用结构]入口脚本" target="_blank">[应用结构]入口脚本</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/yii2/1.htm">yii2</a>
                                    <div>入口脚本 
入口脚本是应用启动流程中的第一环,一个应用(不管是网页应用还是控制台应用)只有一个入口脚本。终端用户的请求通过入口脚本实例化应用并将将请求转发到应用。 
Web 应用的入口脚本必须放在终端用户能够访问的目录下,通常命名为 index.php,也可以使用 Web 服务器能定位到的其他名称。 
控制台应用的入口脚本一般在应用根目录下命名为 yii(后缀为.php),该文</div>
                                </li>
                                <li><a href="/article/2862.htm"
                                       title="haoop shell命令" target="_blank">haoop shell命令</a>
                                    <span class="text-muted">eksliang</span>
<a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a><a class="tag" taget="_blank" href="/search/hadoop+shell/1.htm">hadoop shell</a>
                                    <div> 
 cat 
 chgrp 
 chmod 
 chown 
 copyFromLocal 
 copyToLocal 
 cp 
 du 
 dus 
 expunge 
 get 
 getmerge 
 ls 
 lsr 
 mkdir 
 movefromLocal 
 mv 
 put 
 rm 
 rmr 
 setrep 
 stat 
 tail 
 test 
 text 
 </div>
                                </li>
                                <li><a href="/article/2989.htm"
                                       title="MultiStateView不同的状态下显示不同的界面" target="_blank">MultiStateView不同的状态下显示不同的界面</a>
                                    <span class="text-muted">gundumw100</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                                    <div>只要将指定的view放在该控件里面,可以该view在不同的状态下显示不同的界面,这对ListView很有用,比如加载界面,空白界面,错误界面。而且这些见面由你指定布局,非常灵活。 
 
PS:ListView虽然可以设置一个EmptyView,但使用起来不方便,不灵活,有点累赘。 
 
 

<com.kennyc.view.MultiStateView xmlns:android=&qu</div>
                                </li>
                                <li><a href="/article/3116.htm"
                                       title="jQuery实现页面内锚点平滑跳转" target="_blank">jQuery实现页面内锚点平滑跳转</a>
                                    <span class="text-muted">ini</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/html/1.htm">html</a><a class="tag" taget="_blank" href="/search/jquery/1.htm">jquery</a><a class="tag" taget="_blank" href="/search/html5/1.htm">html5</a><a class="tag" taget="_blank" href="/search/css/1.htm">css</a>
                                    <div>平时我们做导航滚动到内容都是通过锚点来做,刷的一下就直接跳到内容了,没有一丝的滚动效果,而且 url 链接最后会有“小尾巴”,就像#keleyi,今天我就介绍一款 jquery 做的滚动的特效,既可以设置滚动速度,又可以在 url 链接上没有“小尾巴”。 
  
效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/37.htmHTML文件代码: 
&</div>
                                </li>
                                <li><a href="/article/3243.htm"
                                       title="kafka offset迁移" target="_blank">kafka offset迁移</a>
                                    <span class="text-muted">kane_xie</span>
<a class="tag" taget="_blank" href="/search/kafka/1.htm">kafka</a>
                                    <div>在早前的kafka版本中(0.8.0),offset是被存储在zookeeper中的。 
  
到当前版本(0.8.2)为止,kafka同时支持offset存储在zookeeper和offset manager(broker)中。 
  
从官方的说明来看,未来offset的zookeeper存储将会被弃用。因此现有的基于kafka的项目如果今后计划保持更新的话,可以考虑在合适</div>
                                </li>
                                <li><a href="/article/3370.htm"
                                       title="android > 搭建 cordova 环境" target="_blank">android > 搭建 cordova 环境</a>
                                    <span class="text-muted">mft8899</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                                    <div>  
1 , 安装 node.js   
     http://nodejs.org 
     
node -v   查看版本 
  
2, 安装 npm 
  
可以先从  https://github.com/isaacs/npm/tags  下载 源码 解压到</div>
                                </li>
                                <li><a href="/article/3497.htm"
                                       title="java封装的比较器,比较是否全相同,获取不同字段名字" target="_blank">java封装的比较器,比较是否全相同,获取不同字段名字</a>
                                    <span class="text-muted">qifeifei</span>

                                    <div> 非常实用的java比较器,贴上代码: 
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

i</div>
                                </li>
                                <li><a href="/article/3624.htm"
                                       title="记录一些函数用法" target="_blank">记录一些函数用法</a>
                                    <span class="text-muted">.Aky.</span>
<a class="tag" taget="_blank" href="/search/%E4%BD%8D%E8%BF%90%E7%AE%97/1.htm">位运算</a><a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a><a class="tag" taget="_blank" href="/search/%E5%87%BD%E6%95%B0/1.htm">函数</a><a class="tag" taget="_blank" href="/search/IP/1.htm">IP</a>
                                    <div>高手们照旧忽略。 
想弄个全天朝IP段数据库,找了个今天最新更新的国内所有运营商IP段,copy到文件,用文件函数,字符串函数把玩下。分割出startIp和endIp这样格式写入.txt文件,直接用phpmyadmin导入.csv文件的形式导入。(生命在于折腾,也许你们觉得我傻X,直接下载人家弄好的导入不就可以,做自己的菜鸟,让别人去说吧) 
 
当然用到了ip2long()函数把字符串转为整型数</div>
                                </li>
                                <li><a href="/article/3751.htm"
                                       title="sublime text 3 rust" target="_blank">sublime text 3 rust</a>
                                    <span class="text-muted">wudixiaotie</span>
<a class="tag" taget="_blank" href="/search/Sublime+Text/1.htm">Sublime Text</a>
                                    <div>1.sublime text 3 => install package => Rust 
2.cd ~/.config/sublime-text-3/Packages 
3.mkdir rust 
4.git clone https://github.com/sp0/rust-style 
5.cd rust-style 
6.cargo build --release 
7.ctrl</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>