Commit 171d7358 authored by Bärtschi Marc's avatar Bärtschi Marc


parent 04bd5cd5
package main
import (
apiv1 ""
metav1 ""
pb ""
type dnsLock struct {
dns pb.DNS
mutex sync.Mutex
var dnsList dnsLock
func main() {
var kubeconfig *string
if home := homedir.HomeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
if err != nil {
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
deploymentsClient := clientset.ExtensionsV1beta1().Ingresses(apiv1.NamespaceAll)
fmt.Printf("Listing Ingresses in namespace %q:\n", apiv1.NamespaceAll)
list, err := deploymentsClient.List(metav1.ListOptions{})
if err != nil {
// TODO: implement change check
dnsList.dns = pb.DNS{
LastCheck: int64(time.Now().Unix()),
Record: []*pb.Record{},
for _, d := range list.Items {
for _, h := range d.Spec.Rules {
fmt.Printf(" * %s : %s\n", d.Name, h.Host)
dns.Record = append(dns.Record, &pb.Record{
Name: h.Host + ".",
RecordType: "A",
Content: "",
Ttl: 100,
dns.Record = append(dns.Record, &pb.Record{
Name: h.Host + ".",
RecordType: "AAAA",
Content: "fe80::250:56ff:fec0:1",
Ttl: 101,
......@@ -8,6 +8,8 @@ import (
fmt "fmt"
proto ""
grpc ""
codes ""
status ""
math "math"
......@@ -148,19 +150,20 @@ func init() {
func init() { proto.RegisterFile("dns.proto", fileDescriptor_638ff8d8aaf3d8ae) }
var fileDescriptor_638ff8d8aaf3d8ae = []byte{
// 183 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0xbd, 0xaa, 0xc2, 0x40,
0x10, 0x85, 0x49, 0x36, 0xc9, 0x25, 0x73, 0x1b, 0x99, 0x6a, 0x0a, 0x91, 0x90, 0x2a, 0x55, 0x8a,
0xf8, 0x08, 0x0a, 0x76, 0x16, 0xab, 0x2f, 0x90, 0x9f, 0x05, 0xc5, 0xb8, 0xbb, 0x6c, 0xa6, 0x11,
0x7c, 0x78, 0xc9, 0x44, 0xd1, 0xee, 0xcc, 0xf7, 0x0d, 0x87, 0x19, 0xc8, 0x07, 0x3b, 0xd5, 0x3e,
0x38, 0x76, 0x18, 0xfb, 0xae, 0x3c, 0x80, 0xda, 0x1f, 0x4f, 0xb8, 0x86, 0x7c, 0x6c, 0x27, 0xde,
0x5d, 0x4c, 0x7f, 0xa3, 0xa8, 0x88, 0x2a, 0xa5, 0xbf, 0x00, 0x4b, 0xc8, 0x82, 0xe9, 0x5d, 0x18,
0x28, 0x2e, 0x54, 0xf5, 0xdf, 0x40, 0xed, 0xbb, 0x5a, 0x0b, 0xd1, 0x6f, 0x53, 0x3e, 0x21, 0x5b,
0x08, 0x22, 0x24, 0xb6, 0xbd, 0x1b, 0xa9, 0xc9, 0xb5, 0x64, 0xdc, 0x00, 0x2c, 0x7b, 0xe7, 0x87,
0x37, 0x14, 0x8b, 0xf9, 0x21, 0x48, 0xf0, 0xd7, 0x3b, 0xcb, 0xc6, 0x32, 0x29, 0x91, 0x9f, 0x11,
0x57, 0xa0, 0x98, 0x47, 0x4a, 0xe4, 0xa6, 0x39, 0xce, 0xfd, 0x3e, 0x5c, 0x1d, 0xa5, 0x82, 0x24,
0x37, 0x29, 0xa8, 0xc1, 0x4e, 0x5d, 0x26, 0x8f, 0x6d, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc0,
0x8b, 0xac, 0x1f, 0xe5, 0x00, 0x00, 0x00,
// 204 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0xcd, 0x4a, 0xc5, 0x30,
0x10, 0x85, 0xbd, 0x4d, 0x6d, 0xe9, 0xb8, 0x91, 0x59, 0x05, 0x11, 0x29, 0xd9, 0xd8, 0x55, 0x17,
0xf5, 0x11, 0x2c, 0x74, 0x23, 0x5d, 0xa4, 0xbe, 0x40, 0x7f, 0x02, 0x16, 0x6b, 0x12, 0x92, 0xd9,
0x08, 0x3e, 0xbc, 0x74, 0x6a, 0xf1, 0xee, 0xbe, 0x7c, 0x27, 0x1c, 0xce, 0x40, 0xb1, 0xd8, 0x58,
0xfb, 0xe0, 0xc8, 0x61, 0xe2, 0x27, 0xd5, 0x81, 0x68, 0xfb, 0x01, 0x1f, 0xa1, 0xd8, 0xc6, 0x48,
0xaf, 0x1f, 0x66, 0xfe, 0x94, 0x97, 0xf2, 0x52, 0x09, 0xfd, 0x2f, 0x50, 0x41, 0x16, 0xcc, 0xec,
0xc2, 0x22, 0x93, 0x52, 0x54, 0x77, 0x0d, 0xd4, 0x7e, 0xaa, 0x35, 0x1b, 0xfd, 0x97, 0xa8, 0x1f,
0xc8, 0x0e, 0x83, 0x08, 0xa9, 0x1d, 0xbf, 0x0c, 0xd7, 0x14, 0x9a, 0x19, 0x9f, 0x00, 0x8e, 0x7f,
0xef, 0xdf, 0xde, 0xc8, 0x84, 0x93, 0x2b, 0x83, 0x12, 0xf2, 0xd9, 0x59, 0x32, 0x96, 0xa4, 0xe0,
0xf0, 0x7c, 0xe2, 0x3d, 0x08, 0xa2, 0x4d, 0xa6, 0xbc, 0x69, 0xc7, 0xbd, 0xdf, 0x87, 0xd5, 0xc9,
0x5b, 0x56, 0xcc, 0xcd, 0x33, 0x88, 0xc5, 0x46, 0x2c, 0x01, 0x3a, 0x43, 0x6d, 0x3f, 0xbc, 0xad,
0x91, 0x30, 0xdf, 0x67, 0xb6, 0xfd, 0xf0, 0x70, 0x82, 0xba, 0x99, 0x32, 0x3e, 0xfd, 0xe5, 0x37,
0x00, 0x00, 0xff, 0xff, 0xf6, 0x8a, 0x92, 0x4f, 0x07, 0x01, 0x00, 0x00,
// Reference imports to suppress errors if they are not otherwise used.
......@@ -175,6 +178,7 @@ const _ = grpc.SupportPackageIsVersion4
// For semantics around ctx use and closing/ending streaming RPCs, please refer to
type DnsClient interface {
GetDNSList(ctx context.Context, in *DNS, opts ...grpc.CallOption) (*DNS, error)
type dnsClient struct {
......@@ -185,22 +189,59 @@ func NewDnsClient(cc *grpc.ClientConn) DnsClient {
return &dnsClient{cc}
func (c *dnsClient) GetDNSList(ctx context.Context, in *DNS, opts ...grpc.CallOption) (*DNS, error) {
out := new(DNS)
err :=, "/pb.dns/GetDNSList", in, out, opts...)
if err != nil {
return nil, err
return out, nil
// DnsServer is the server API for Dns service.
type DnsServer interface {
GetDNSList(context.Context, *DNS) (*DNS, error)
// UnimplementedDnsServer can be embedded to have forward compatible implementations.
type UnimplementedDnsServer struct {
func (*UnimplementedDnsServer) GetDNSList(ctx context.Context, req *DNS) (*DNS, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetDNSList not implemented")
func RegisterDnsServer(s *grpc.Server, srv DnsServer) {
s.RegisterService(&_Dns_serviceDesc, srv)
func _Dns_GetDNSList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DNS)
if err := dec(in); err != nil {
return nil, err
if interceptor == nil {
return srv.(DnsServer).GetDNSList(ctx, in)
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.dns/GetDNSList",
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DnsServer).GetDNSList(ctx, req.(*DNS))
return interceptor(ctx, in, info, handler)
var _Dns_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.dns",
HandlerType: (*DnsServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},
Metadata: "dns.proto",
Methods: []grpc.MethodDesc{
MethodName: "GetDNSList",
Handler: _Dns_GetDNSList_Handler,
Streams: []grpc.StreamDesc{},
Metadata: "dns.proto",
......@@ -21,5 +21,5 @@ message Record {
service dns {
rpc GetDNSList(DNS) returns (DNS) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment