• 如何创建静态Pod


    创建静态Pod

    1. 找到kubelet config 文件

    ## 查看配置, 找到 staticPodPath
    cat /var/lib/kubelet/config.yaml
    

    这是默认的 config.yaml文件

    apiVersion: kubelet.config.k8s.io/v1beta1
    authentication:
      anonymous:
        enabled: false
      webhook:
        cacheTTL: 0s
        enabled: true
      x509:
        clientCAFile: /etc/kubernetes/pki/ca.crt
    authorization:
      mode: Webhook
      webhook:
        cacheAuthorizedTTL: 0s
        cacheUnauthorizedTTL: 0s
    cgroupDriver: systemd
    clusterDNS:
    - 10.1.0.10
    clusterDomain: cluster.local
    cpuManagerReconcilePeriod: 0s
    evictionPressureTransitionPeriod: 0s
    fileCheckFrequency: 0s
    healthzBindAddress: 127.0.0.1
    healthzPort: 10248
    httpCheckFrequency: 0s
    imageMinimumGCAge: 0s
    kind: KubeletConfiguration
    logging: {}
    memorySwap: {}
    nodeStatusReportFrequency: 0s
    nodeStatusUpdateFrequency: 0s
    rotateCertificates: true
    runtimeRequestTimeout: 0s
    shutdownGracePeriod: 0s
    shutdownGracePeriodCriticalPods: 0s
    staticPodPath: /etc/kubernetes/manifests
    streamingConnectionIdleTimeout: 0s
    syncFrequency: 0s
    volumeStatsAggPeriod: 0s
    

    2. 在目录 staticPodPath 中放入一个static-web.yaml文件

    apiVersion: v1
    kind: Pod
    metadata:
      name: static-web
      labels:
        name: static-web
    spec:
      containers:
      - name: static-web
        image: nginx
        ports:
        - name: web
          containerPort: 80
    

    3. 重启 kubelet

    ## 执行如下命令使新增参数生效
    systemctl stop kubelet
    systemctl daemon-reload
    systemctl start kubelet
    

    4. 测试

    ## 在当前node,查看 docker 容器是否启动
    docker ps 
    
    ## 在master上查看pod是否启动
    kubectl get pods 
    
    ## 在master上尝试删除这个pod
    [root@master ~]# kubectl delete pod static-web-worker1
    pod "static-web-worker1" deleted
    
    ## 再看看是否删除了,如果不能删除,说明这是个static pod
    [root@master ~]# kubectl get pods
    NAME                        READY   STATUS    RESTARTS      AGE
    static-web-worker1          1/1     Running   0             12s
    
    
  • 相关阅读:
    前缀和
    hdu6290奢侈的旅行
    make_pair
    New Year and Buggy Bot
    STL next_permutation 算法原理和自行实现
    前端面试题集合
    node设置cookie
    黑客与geek
    xss
    node async
  • 原文地址:https://www.cnblogs.com/Dannier/p/15787506.html
Copyright © 2020-2023  润新知