mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
Specify hostname, subdomain via annotation on podspec.
The hostname is a DNS A record, if the subdomain maps to a service name in the same namespace
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## Version 1.14 (Mar 4 2016 Abhishek Shah <abshah@google.com>)
|
||||
- If Endpoint has hostnames-map annotation (endpoints.net.beta.kubernetes.io/hostnames-map),
|
||||
the hostnames supplied via the annotation will be used to generate A Records for Headless Service.
|
||||
|
||||
## Version 1.13 (Mar 1 2016 Prashanth.B <beeps@google.com>)
|
||||
- Synchronously wait for the Kubernetes service at startup.
|
||||
- Add a SIGTERM/SIGINT handler.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
.PHONY: all kube2sky container push clean test
|
||||
|
||||
TAG = 1.13
|
||||
TAG = 1.14
|
||||
PREFIX = gcr.io/google_containers
|
||||
|
||||
all: container
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
skymsg "github.com/skynetservices/skydns/msg"
|
||||
flag "github.com/spf13/pflag"
|
||||
kapi "k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/endpoints"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
kcache "k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
@@ -46,6 +47,7 @@ import (
|
||||
kselector "k8s.io/kubernetes/pkg/fields"
|
||||
etcdutil "k8s.io/kubernetes/pkg/storage/etcd/util"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
"k8s.io/kubernetes/pkg/util/validation"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
)
|
||||
|
||||
@@ -159,14 +161,28 @@ func getSkyMsg(ip string, port int) *skymsg.Service {
|
||||
}
|
||||
|
||||
func (ks *kube2sky) generateRecordsForHeadlessService(subdomain string, e *kapi.Endpoints, svc *kapi.Service) error {
|
||||
glog.V(4).Infof("Endpoints Annotations: %v", e.Annotations)
|
||||
for idx := range e.Subsets {
|
||||
for subIdx := range e.Subsets[idx].Addresses {
|
||||
b, err := json.Marshal(getSkyMsg(e.Subsets[idx].Addresses[subIdx].IP, 0))
|
||||
endpointIP := e.Subsets[idx].Addresses[subIdx].IP
|
||||
b, err := json.Marshal(getSkyMsg(endpointIP, 0))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
recordValue := string(b)
|
||||
recordLabel := getHash(recordValue)
|
||||
if serializedPodHostnames := e.Annotations[endpoints.PodHostnamesAnnotation]; len(serializedPodHostnames) > 0 {
|
||||
podHostnames := map[string]endpoints.HostRecord{}
|
||||
err := json.Unmarshal([]byte(serializedPodHostnames), &podHostnames)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if hostRecord, exists := podHostnames[string(endpointIP)]; exists {
|
||||
if validation.IsDNS1123Label(hostRecord.HostName) {
|
||||
recordLabel = hostRecord.HostName
|
||||
}
|
||||
}
|
||||
}
|
||||
recordKey := buildDNSNameString(subdomain, recordLabel)
|
||||
|
||||
glog.V(2).Infof("Setting DNS record: %v -> %q\n", recordKey, recordValue)
|
||||
|
||||
@@ -47,7 +47,7 @@ spec:
|
||||
- name: etcd-storage
|
||||
mountPath: /var/etcd/data
|
||||
- name: kube2sky
|
||||
image: gcr.io/google_containers/kube2sky:1.13
|
||||
image: gcr.io/google_containers/kube2sky:1.14
|
||||
resources:
|
||||
# TODO: Set memory limits when we've profiled the container for large
|
||||
# clusters, then set request = limit to keep this container in
|
||||
|
||||
Reference in New Issue
Block a user