mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Update the DNS template from cluster/addons/dns and combine into one file. Make DNS working on docker and docker-multinode
This commit is contained in:
parent
df234d83cd
commit
e9af6c34af
@ -21,7 +21,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: etcd
|
- name: etcd
|
||||||
image: gcr.io/google_containers/etcd:2.0.9
|
image: gcr.io/google_containers/etcd-amd64:2.2.1
|
||||||
resources:
|
resources:
|
||||||
# keep request = limit to keep this container in guaranteed class
|
# keep request = limit to keep this container in guaranteed class
|
||||||
limits:
|
limits:
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
"image": "gcr.io/google_containers/hyperkube-ARCH:VERSION",
|
"image": "gcr.io/google_containers/hyperkube-ARCH:VERSION",
|
||||||
"command": [
|
"command": [
|
||||||
"/setup-files.sh",
|
"/setup-files.sh",
|
||||||
"IP:10.0.0.1"
|
"IP:10.0.0.1,DNS:kubernetes,DNS:kubernetes.default,DNS:kubernetes.default.svc,DNS:kubernetes.default.svc.cluster.local"
|
||||||
],
|
],
|
||||||
"volumeMounts": [
|
"volumeMounts": [
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
"image": "gcr.io/google_containers/hyperkube-ARCH:VERSION",
|
"image": "gcr.io/google_containers/hyperkube-ARCH:VERSION",
|
||||||
"command": [
|
"command": [
|
||||||
"/setup-files.sh",
|
"/setup-files.sh",
|
||||||
"IP:10.0.0.1"
|
"IP:10.0.0.1,DNS:kubernetes,DNS:kubernetes.default,DNS:kubernetes.default.svc,DNS:kubernetes.default.svc.cluster.local"
|
||||||
],
|
],
|
||||||
"volumeMounts": [
|
"volumeMounts": [
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,9 @@ echo "admin,admin,admin" > /data/basic_auth.csv
|
|||||||
|
|
||||||
# Create HTTPS certificates
|
# Create HTTPS certificates
|
||||||
groupadd -f -r kube-cert-test
|
groupadd -f -r kube-cert-test
|
||||||
CERT_DIR=/data CERT_GROUP=kube-cert-test /make-ca-cert.sh $(hostname -i) ${EXTRA_SANS}
|
|
||||||
|
# hostname -I gets the ip of the node
|
||||||
|
CERT_DIR=/data CERT_GROUP=kube-cert-test /make-ca-cert.sh $(hostname -I | awk '{print $1}') ${EXTRA_SANS}
|
||||||
|
|
||||||
# Create known tokens for service accounts
|
# Create known tokens for service accounts
|
||||||
echo "$(create_token),admin,admin" >> /data/known_tokens.csv
|
echo "$(create_token),admin,admin" >> /data/known_tokens.csv
|
||||||
|
@ -32,55 +32,42 @@ Documentation for other releases can be found at
|
|||||||
|
|
||||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||||
|
|
||||||
## Deploy DNS
|
## Deploy DNS on `docker` and `docker-multinode`
|
||||||
|
|
||||||
### Get the template file
|
### Get the template file
|
||||||
|
|
||||||
First of all, download the template dns rc and svc file from
|
First of all, download the dns template
|
||||||
|
|
||||||
[skydns-rc template](skydns-rc.yaml.in)
|
[skydns template](skydns.yaml.in)
|
||||||
|
|
||||||
[skydns-svc template](skydns-svc.yaml.in)
|
### Set environment variables
|
||||||
|
|
||||||
### Set env
|
Then you need to set `DNS_REPLICAS`, `DNS_DOMAIN` and `DNS_SERVER_IP` envs
|
||||||
|
|
||||||
Then you need to set `DNS_REPLICAS` , `DNS_DOMAIN` , `DNS_SERVER_IP` , `KUBE_SERVER` ENV.
|
```console
|
||||||
|
|
||||||
```
|
|
||||||
$ export DNS_REPLICAS=1
|
$ export DNS_REPLICAS=1
|
||||||
|
|
||||||
$ export DNS_DOMAIN=cluster.local # specify in startup parameter `--cluster-domain` for containerized kubelet
|
$ export DNS_DOMAIN=cluster.local # specify in startup parameter `--cluster-domain` for containerized kubelet
|
||||||
|
|
||||||
$ export DNS_SERVER_IP=10.0.0.10 # specify in startup parameter `--cluster-dns` for containerized kubelet
|
$ export DNS_SERVER_IP=10.0.0.10 # specify in startup parameter `--cluster-dns` for containerized kubelet
|
||||||
|
|
||||||
$ export KUBE_SERVER=10.10.103.250 # your master server ip, you may change it
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Replace the corresponding value in the template.
|
### Replace the corresponding value in the template and create the pod
|
||||||
|
|
||||||
```
|
```console
|
||||||
$ sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g;s/{kube_server_url}/${KUBE_SERVER}/g;" skydns-rc.yaml.in > ./skydns-rc.yaml
|
$ sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g;s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" skydns.yaml.in > ./skydns.yaml
|
||||||
|
|
||||||
$ sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" skydns-svc.yaml.in > ./skydns-svc.yaml
|
# If the kube-system namespace isn't already created, create it
|
||||||
```
|
$ kubectl get ns
|
||||||
|
$ kubectl create -f ./kube-system.yaml
|
||||||
|
|
||||||
### Use `kubectl` to create skydns rc and service
|
$ kubectl create -f ./skydns.yaml
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
$ kubectl -s "$KUBE_SERVER:8080" --namespace=kube-system create -f ./skydns-rc.yaml
|
|
||||||
|
|
||||||
$ kubectl -s "$KUBE_SERVER:8080" --namespace=kube-system create -f ./skydns-svc.yaml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Test if DNS works
|
### Test if DNS works
|
||||||
|
|
||||||
Follow [this link](../../../cluster/addons/dns/#how-do-i-test-if-it-is-working) to check it out.
|
Follow [this link](../../../cluster/addons/dns/#how-do-i-test-if-it-is-working) to check it out.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||||
[]()
|
[]()
|
||||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: kube-system
|
@ -1,20 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: kube-dns
|
|
||||||
namespace: kube-system
|
|
||||||
labels:
|
|
||||||
k8s-app: kube-dns
|
|
||||||
kubernetes.io/cluster-service: "true"
|
|
||||||
kubernetes.io/name: "KubeDNS"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
k8s-app: kube-dns
|
|
||||||
clusterIP: {{ pillar['dns_server'] }}
|
|
||||||
ports:
|
|
||||||
- name: dns
|
|
||||||
port: 53
|
|
||||||
protocol: UDP
|
|
||||||
- name: dns-tcp
|
|
||||||
port: 53
|
|
||||||
protocol: TCP
|
|
@ -1,31 +1,35 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ReplicationController
|
kind: ReplicationController
|
||||||
metadata:
|
metadata:
|
||||||
name: kube-dns-v8
|
name: kube-dns-v10
|
||||||
namespace: kube-system
|
namespace: kube-system
|
||||||
labels:
|
labels:
|
||||||
k8s-app: kube-dns
|
k8s-app: kube-dns
|
||||||
version: v8
|
version: v10
|
||||||
kubernetes.io/cluster-service: "true"
|
kubernetes.io/cluster-service: "true"
|
||||||
spec:
|
spec:
|
||||||
replicas: {{ pillar['dns_replicas'] }}
|
replicas: {{ pillar['dns_replicas'] }}
|
||||||
selector:
|
selector:
|
||||||
k8s-app: kube-dns
|
k8s-app: kube-dns
|
||||||
version: v8
|
version: v10
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
k8s-app: kube-dns
|
k8s-app: kube-dns
|
||||||
version: v8
|
version: v10
|
||||||
kubernetes.io/cluster-service: "true"
|
kubernetes.io/cluster-service: "true"
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: etcd
|
- name: etcd
|
||||||
image: gcr.io/google_containers/etcd:2.0.9
|
image: gcr.io/google_containers/etcd-amd64:2.2.1
|
||||||
resources:
|
resources:
|
||||||
|
# keep request = limit to keep this container in guaranteed class
|
||||||
limits:
|
limits:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 50Mi
|
memory: 50Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 50Mi
|
||||||
command:
|
command:
|
||||||
- /usr/local/bin/etcd
|
- /usr/local/bin/etcd
|
||||||
- -data-dir
|
- -data-dir
|
||||||
@ -40,25 +44,33 @@ spec:
|
|||||||
- name: etcd-storage
|
- name: etcd-storage
|
||||||
mountPath: /var/etcd/data
|
mountPath: /var/etcd/data
|
||||||
- name: kube2sky
|
- name: kube2sky
|
||||||
image: gcr.io/google_containers/kube2sky:1.11
|
image: gcr.io/google_containers/kube2sky:1.12
|
||||||
resources:
|
resources:
|
||||||
|
# keep request = limit to keep this container in guaranteed class
|
||||||
limits:
|
limits:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 50Mi
|
memory: 50Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 50Mi
|
||||||
args:
|
args:
|
||||||
# command = "/kube2sky"
|
# command = "/kube2sky"
|
||||||
- -domain={{ pillar['dns_domain'] }}
|
- --domain={{ pillar['dns_domain'] }}
|
||||||
- -kube_master_url=http://{kube_server_url}:8080
|
|
||||||
- name: skydns
|
- name: skydns
|
||||||
image: gcr.io/google_containers/skydns:2015-03-11-001
|
image: gcr.io/google_containers/skydns:2015-10-13-8c72f8c
|
||||||
resources:
|
resources:
|
||||||
|
# keep request = limit to keep this container in guaranteed class
|
||||||
limits:
|
limits:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 50Mi
|
memory: 50Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 50Mi
|
||||||
args:
|
args:
|
||||||
# command = "/skydns"
|
# command = "/skydns"
|
||||||
- -machines=http://localhost:4001
|
- -machines=http://127.0.0.1:4001
|
||||||
- -addr=0.0.0.0:53
|
- -addr=0.0.0.0:53
|
||||||
|
- -ns-rotate=false
|
||||||
- -domain={{ pillar['dns_domain'] }}.
|
- -domain={{ pillar['dns_domain'] }}.
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 53
|
- containerPort: 53
|
||||||
@ -74,14 +86,25 @@ spec:
|
|||||||
scheme: HTTP
|
scheme: HTTP
|
||||||
initialDelaySeconds: 30
|
initialDelaySeconds: 30
|
||||||
timeoutSeconds: 5
|
timeoutSeconds: 5
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /healthz
|
||||||
|
port: 8080
|
||||||
|
scheme: HTTP
|
||||||
|
initialDelaySeconds: 1
|
||||||
|
timeoutSeconds: 5
|
||||||
- name: healthz
|
- name: healthz
|
||||||
image: gcr.io/google_containers/exechealthz:1.0
|
image: gcr.io/google_containers/exechealthz:1.0
|
||||||
resources:
|
resources:
|
||||||
|
# keep request = limit to keep this container in guaranteed class
|
||||||
limits:
|
limits:
|
||||||
cpu: 10m
|
cpu: 10m
|
||||||
memory: 20Mi
|
memory: 20Mi
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 20Mi
|
||||||
args:
|
args:
|
||||||
- -cmd=nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} localhost >/dev/null
|
- -cmd=nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} 127.0.0.1 >/dev/null
|
||||||
- -port=8080
|
- -port=8080
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
@ -90,3 +113,24 @@ spec:
|
|||||||
- name: etcd-storage
|
- name: etcd-storage
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
dnsPolicy: Default # Don't use cluster DNS.
|
dnsPolicy: Default # Don't use cluster DNS.
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: kube-dns
|
||||||
|
namespace: kube-system
|
||||||
|
labels:
|
||||||
|
k8s-app: kube-dns
|
||||||
|
kubernetes.io/cluster-service: "true"
|
||||||
|
kubernetes.io/name: "KubeDNS"
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
k8s-app: kube-dns
|
||||||
|
clusterIP: {{ pillar['dns_server'] }}
|
||||||
|
ports:
|
||||||
|
- name: dns
|
||||||
|
port: 53
|
||||||
|
protocol: UDP
|
||||||
|
- name: dns-tcp
|
||||||
|
port: 53
|
||||||
|
protocol: TCP
|
Loading…
Reference in New Issue
Block a user