how to change kube-dns service ip

8/31/2019

when install kubernetes dashboard using this command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

I check kubernetes service state like this:

kubectl get events --namespace=kube-system

It give me this tip:

LAST SEEN   TYPE      REASON                OBJECT                   MESSAGE
2m38s       Warning   ClusterIPOutOfRange   service/kube-dns         Cluster IP 10.43.0.10 is not within the service CIDR 10.254.0.0/16; please recreate service
2m38s       Warning   ClusterIPOutOfRange   service/metrics-server   Cluster IP 10.43.96.112 is not within the service CIDR 10.254.0.0/16; please recreate service

is there any way to change my kube-dns service ip into CIDR range(I search from internet and no one change to ip by hand,should I tweak the kube-dns component config)?This is version info:

[root@iZuf63refzweg1d9dh94t8Z ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:23:26Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:15:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

this is cluster dump:

{
    "kind": "NodeList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/nodes",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "EventList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/kube-system/events",
        "resourceVersion": "8044226"
    },
    "items": [
        {
            "metadata": {
                "name": "kube-dns.15bf7a181c6f8459",
                "namespace": "kube-system",
                "selfLink": "/api/v1/namespaces/kube-system/events/kube-dns.15bf7a181c6f8459",
                "uid": "3adfac28-ca39-4cc0-a516-08220a4be8b5",
                "resourceVersion": "8044216",
                "creationTimestamp": "2019-08-29T19:03:59Z"
            },
            "involvedObject": {
                "kind": "Service",
                "namespace": "kube-system",
                "name": "kube-dns",
                "uid": "2256b0f5-80f5-11e9-b3ce-00163e086f0c",
                "apiVersion": "v1",
                "resourceVersion": "379"
            },
            "reason": "ClusterIPOutOfRange",
            "message": "Cluster IP 10.43.0.10 is not within the service CIDR 10.254.0.0/16; please recreate service",
            "source": {
                "component": "ipallocator-repair-controller"
            },
            "firstTimestamp": "2019-08-29T19:03:59Z",
            "lastTimestamp": "2019-09-05T15:10:58Z",
            "count": 3283,
            "type": "Warning",
            "eventTime": null,
            "reportingComponent": "",
            "reportingInstance": ""
        },
        {
            "metadata": {
                "name": "metrics-server.15bf7a181c8012e4",
                "namespace": "kube-system",
                "selfLink": "/api/v1/namespaces/kube-system/events/metrics-server.15bf7a181c8012e4",
                "uid": "0be9374b-b497-4a9d-86d2-2b75da47b659",
                "resourceVersion": "8044217",
                "creationTimestamp": "2019-08-29T19:03:59Z"
            },
            "involvedObject": {
                "kind": "Service",
                "namespace": "kube-system",
                "name": "metrics-server",
                "uid": "255955e6-80f5-11e9-b3ce-00163e086f0c",
                "apiVersion": "v1",
                "resourceVersion": "427"
            },
            "reason": "ClusterIPOutOfRange",
            "message": "Cluster IP 10.43.96.112 is not within the service CIDR 10.254.0.0/16; please recreate service",
            "source": {
                "component": "ipallocator-repair-controller"
            },
            "firstTimestamp": "2019-08-29T19:03:59Z",
            "lastTimestamp": "2019-09-05T15:10:58Z",
            "count": 3283,
            "type": "Warning",
            "eventTime": null,
            "reportingComponent": "",
            "reportingInstance": ""
        }
    ]
}
{
    "kind": "ReplicationControllerList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/kube-system/replicationcontrollers",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "ServiceList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/kube-system/services",
        "resourceVersion": "8044226"
    },
    "items": [
        {
            "metadata": {
                "name": "kube-dns",
                "namespace": "kube-system",
                "selfLink": "/api/v1/namespaces/kube-system/services/kube-dns",
                "uid": "2256b0f5-80f5-11e9-b3ce-00163e086f0c",
                "resourceVersion": "379",
                "creationTimestamp": "2019-05-28T03:03:14Z",
                "labels": {
                    "addonmanager.kubernetes.io/mode": "Reconcile",
                    "k8s-app": "kube-dns",
                    "kubernetes.io/cluster-service": "true",
                    "kubernetes.io/name": "KubeDNS"
                },
                "annotations": {
                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"addonmanager.kubernetes.io/mode\":\"Reconcile\",\"k8s-app\":\"kube-dns\",\"kubernetes.io/cluster-service\":\"true\",\"kubernetes.io/name\":\"KubeDNS\"},\"name\":\"kube-dns\",\"namespace\":\"kube-system\"},\"spec\":{\"clusterIP\":\"10.43.0.10\",\"ports\":[{\"name\":\"dns\",\"port\":53,\"protocol\":\"UDP\"},{\"name\":\"dns-tcp\",\"port\":53,\"protocol\":\"TCP\"}],\"selector\":{\"k8s-app\":\"kube-dns\"}}}\n"
                }
            },
            "spec": {
                "ports": [
                    {
                        "name": "dns",
                        "protocol": "UDP",
                        "port": 53,
                        "targetPort": 53
                    },
                    {
                        "name": "dns-tcp",
                        "protocol": "TCP",
                        "port": 53,
                        "targetPort": 53
                    }
                ],
                "selector": {
                    "k8s-app": "kube-dns"
                },
                "clusterIP": "10.43.0.10",
                "type": "ClusterIP",
                "sessionAffinity": "None"
            },
            "status": {
                "loadBalancer": {}
            }
        },
        {
            "metadata": {
                "name": "metrics-server",
                "namespace": "kube-system",
                "selfLink": "/api/v1/namespaces/kube-system/services/metrics-server",
                "uid": "255955e6-80f5-11e9-b3ce-00163e086f0c",
                "resourceVersion": "427",
                "creationTimestamp": "2019-05-28T03:03:19Z",
                "labels": {
                    "kubernetes.io/name": "Metrics-server"
                },
                "annotations": {
                    "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"kubernetes.io/name\":\"Metrics-server\"},\"name\":\"metrics-server\",\"namespace\":\"kube-system\"},\"spec\":{\"ports\":[{\"port\":443,\"protocol\":\"TCP\",\"targetPort\":443}],\"selector\":{\"k8s-app\":\"metrics-server\"}}}\n"
                }
            },
            "spec": {
                "ports": [
                    {
                        "protocol": "TCP",
                        "port": 443,
                        "targetPort": 443
                    }
                ],
                "selector": {
                    "k8s-app": "metrics-server"
                },
                "clusterIP": "10.43.96.112",
                "type": "ClusterIP",
                "sessionAffinity": "None"
            },
            "status": {
                "loadBalancer": {}
            }
        }
    ]
}
{
    "kind": "DaemonSetList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/kube-system/daemonsets",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "DeploymentList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/kube-system/deployments",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "ReplicaSetList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/kube-system/replicasets",
        "resourceVersion": "73105"
    },
    "items": [
        {
            "metadata": {
                "name": "kubernetes-dashboard-7d75c474bb",
                "namespace": "kube-system",
                "selfLink": "/apis/apps/v1/namespaces/kube-system/replicasets/kubernetes-dashboard-7d75c474bb",
                "uid": "1b426257-5d74-4f50-b368-45f65d926fdf",
                "resourceVersion": "57629",
                "generation": 1,
                "creationTimestamp": "2019-08-29T15:11:10Z",
                "labels": {
                    "k8s-app": "kubernetes-dashboard",
                    "pod-template-hash": "7d75c474bb"
                },
                "annotations": {
                    "deployment.kubernetes.io/desired-replicas": "1",
                    "deployment.kubernetes.io/max-replicas": "2",
                    "deployment.kubernetes.io/revision": "1"
                },
                "ownerReferences": [
                    {
                        "apiVersion": "apps/v1",
                        "kind": "Deployment",
                        "name": "kubernetes-dashboard",
                        "uid": "c5b2daaa-d306-43b1-ab0a-9745beb865de",
                        "controller": true,
                        "blockOwnerDeletion": true
                    }
                ]
            },
            "spec": {
                "replicas": 1,
                "selector": {
                    "matchLabels": {
                        "k8s-app": "kubernetes-dashboard",
                        "pod-template-hash": "7d75c474bb"
                    }
                },
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "labels": {
                            "k8s-app": "kubernetes-dashboard",
                            "pod-template-hash": "7d75c474bb"
                        }
                    },
                    "spec": {
                        "volumes": [
                            {
                                "name": "kubernetes-dashboard-certs",
                                "secret": {
                                    "secretName": "kubernetes-dashboard-certs",
                                    "defaultMode": 420
                                }
                            },
                            {
                                "name": "tmp-volume",
                                "emptyDir": {}
                            }
                        ],
                        "containers": [
                            {
                                "name": "kubernetes-dashboard",
                                "image": "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1",
                                "args": [
                                    "--auto-generate-certificates"
                                ],
                                "ports": [
                                    {
                                        "containerPort": 8443,
                                        "protocol": "TCP"
                                    }
                                ],
                                "resources": {},
                                "volumeMounts": [
                                    {
                                        "name": "kubernetes-dashboard-certs",
                                        "mountPath": "/certs"
                                    },
                                    {
                                        "name": "tmp-volume",
                                        "mountPath": "/tmp"
                                    }
                                ],
                                "livenessProbe": {
                                    "httpGet": {
                                        "path": "/",
                                        "port": 8443,
                                        "scheme": "HTTPS"
                                    },
                                    "initialDelaySeconds": 30,
                                    "timeoutSeconds": 30,
                                    "periodSeconds": 10,
                                    "successThreshold": 1,
                                    "failureThreshold": 3
                                },
                                "terminationMessagePath": "/dev/termination-log",
                                "terminationMessagePolicy": "File",
                                "imagePullPolicy": "IfNotPresent"
                            }
                        ],
                        "restartPolicy": "Always",
                        "terminationGracePeriodSeconds": 30,
                        "dnsPolicy": "ClusterFirst",
                        "serviceAccountName": "kubernetes-dashboard",
                        "serviceAccount": "kubernetes-dashboard",
                        "securityContext": {},
                        "schedulerName": "default-scheduler",
                        "tolerations": [
                            {
                                "key": "node-role.kubernetes.io/master",
                                "effect": "NoSchedule"
                            }
                        ]
                    }
                }
            },
            "status": {
                "replicas": 1,
                "fullyLabeledReplicas": 1,
                "observedGeneration": 1
            }
        }
    ]
}
{
    "kind": "PodList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/kube-system/pods",
        "resourceVersion": "73105"
    },
    "items": [
        {
            "metadata": {
                "name": "kubernetes-dashboard-7d75c474bb-b2lwd",
                "generateName": "kubernetes-dashboard-7d75c474bb-",
                "namespace": "kube-system",
                "selfLink": "/api/v1/namespaces/kube-system/pods/kubernetes-dashboard-7d75c474bb-b2lwd",
                "uid": "d4013a3c-7688-4a00-8acf-e5e49c10c772",
                "resourceVersion": "57626",
                "creationTimestamp": "2019-08-29T15:11:10Z",
                "labels": {
                    "k8s-app": "kubernetes-dashboard",
                    "pod-template-hash": "7d75c474bb"
                },
                "ownerReferences": [
                    {
                        "apiVersion": "apps/v1",
                        "kind": "ReplicaSet",
                        "name": "kubernetes-dashboard-7d75c474bb",
                        "uid": "1b426257-5d74-4f50-b368-45f65d926fdf",
                        "controller": true,
                        "blockOwnerDeletion": true
                    }
                ]
            },
            "spec": {
                "volumes": [
                    {
                        "name": "kubernetes-dashboard-certs",
                        "secret": {
                            "secretName": "kubernetes-dashboard-certs",
                            "defaultMode": 420
                        }
                    },
                    {
                        "name": "tmp-volume",
                        "emptyDir": {}
                    },
                    {
                        "name": "kubernetes-dashboard-token-7k8wl",
                        "secret": {
                            "secretName": "kubernetes-dashboard-token-7k8wl",
                            "defaultMode": 420
                        }
                    }
                ],
                "containers": [
                    {
                        "name": "kubernetes-dashboard",
                        "image": "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1",
                        "args": [
                            "--auto-generate-certificates"
                        ],
                        "ports": [
                            {
                                "containerPort": 8443,
                                "protocol": "TCP"
                            }
                        ],
                        "resources": {},
                        "volumeMounts": [
                            {
                                "name": "kubernetes-dashboard-certs",
                                "mountPath": "/certs"
                            },
                            {
                                "name": "tmp-volume",
                                "mountPath": "/tmp"
                            },
                            {
                                "name": "kubernetes-dashboard-token-7k8wl",
                                "readOnly": true,
                                "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
                            }
                        ],
                        "livenessProbe": {
                            "httpGet": {
                                "path": "/",
                                "port": 8443,
                                "scheme": "HTTPS"
                            },
                            "initialDelaySeconds": 30,
                            "timeoutSeconds": 30,
                            "periodSeconds": 10,
                            "successThreshold": 1,
                            "failureThreshold": 3
                        },
                        "terminationMessagePath": "/dev/termination-log",
                        "terminationMessagePolicy": "File",
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "restartPolicy": "Always",
                "terminationGracePeriodSeconds": 30,
                "dnsPolicy": "ClusterFirst",
                "serviceAccountName": "kubernetes-dashboard",
                "serviceAccount": "kubernetes-dashboard",
                "securityContext": {},
                "schedulerName": "default-scheduler",
                "tolerations": [
                    {
                        "key": "node-role.kubernetes.io/master",
                        "effect": "NoSchedule"
                    }
                ],
                "enableServiceLinks": true
            },
            "status": {
                "phase": "Pending",
                "conditions": [
                    {
                        "type": "PodScheduled",
                        "status": "False",
                        "lastProbeTime": null,
                        "lastTransitionTime": "2019-08-29T15:11:10Z",
                        "reason": "Unschedulable",
                        "message": "no nodes available to schedule pods"
                    }
                ],
                "qosClass": "BestEffort"
            }
        }
    ]
}
==== START logs for container kubernetes-dashboard of pod kube-system/kubernetes-dashboard-7d75c474bb-b2lwd ====
==== END logs for container kubernetes-dashboard of pod kube-system/kubernetes-dashboard-7d75c474bb-b2lwd ====
{
    "kind": "EventList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/default/events",
        "resourceVersion": "8044226"
    },
    "items": [
        {
            "metadata": {
                "name": "kubernetes.15bf7a181c3cf6a8",
                "namespace": "default",
                "selfLink": "/api/v1/namespaces/default/events/kubernetes.15bf7a181c3cf6a8",
                "uid": "4502f2e2-efd1-4707-b402-bfb16194cd52",
                "resourceVersion": "8044213",
                "creationTimestamp": "2019-08-29T19:03:59Z"
            },
            "involvedObject": {
                "kind": "Service",
                "namespace": "default",
                "name": "kubernetes",
                "uid": "089121d4-80f5-11e9-b3ce-00163e086f0c",
                "apiVersion": "v1",
                "resourceVersion": "6"
            },
            "reason": "ClusterIPOutOfRange",
            "message": "Cluster IP 10.43.0.1 is not within the service CIDR 10.254.0.0/16; please recreate service",
            "source": {
                "component": "ipallocator-repair-controller"
            },
            "firstTimestamp": "2019-08-29T19:03:59Z",
            "lastTimestamp": "2019-09-05T15:10:58Z",
            "count": 3283,
            "type": "Warning",
            "eventTime": null,
            "reportingComponent": "",
            "reportingInstance": ""
        }
    ]
}
{
    "kind": "ReplicationControllerList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/default/replicationcontrollers",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "ServiceList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/default/services",
        "resourceVersion": "8044226"
    },
    "items": [
        {
            "metadata": {
                "name": "kubernetes",
                "namespace": "default",
                "selfLink": "/api/v1/namespaces/default/services/kubernetes",
                "uid": "089121d4-80f5-11e9-b3ce-00163e086f0c",
                "resourceVersion": "6",
                "creationTimestamp": "2019-05-28T03:02:31Z",
                "labels": {
                    "component": "apiserver",
                    "provider": "kubernetes"
                }
            },
            "spec": {
                "ports": [
                    {
                        "name": "https",
                        "protocol": "TCP",
                        "port": 443,
                        "targetPort": 6443
                    }
                ],
                "clusterIP": "10.43.0.1",
                "type": "ClusterIP",
                "sessionAffinity": "None"
            },
            "status": {
                "loadBalancer": {}
            }
        }
    ]
}
{
    "kind": "DaemonSetList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/default/daemonsets",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "DeploymentList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/default/deployments",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "ReplicaSetList",
    "apiVersion": "apps/v1",
    "metadata": {
        "selfLink": "/apis/apps/v1/namespaces/default/replicasets",
        "resourceVersion": "73105"
    },
    "items": []
}
{
    "kind": "PodList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/default/pods",
        "resourceVersion": "73105"
    },
    "items": []
}
Cluster info dumped to standard output
-- Dolphin
kubernetes

0 Answers