Hello community, here is the log from the commit of package kubic-control for openSUSE:Factory checked in at 2020-01-13 22:15:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kubic-control (Old) and /work/SRC/openSUSE:Factory/.kubic-control.new.6675 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kubic-control" Mon Jan 13 22:15:29 2020 rev:12 rq:760991 version:0.9.1 Changes: -------- --- /work/SRC/openSUSE:Factory/kubic-control/kubic-control.changes 2019-11-12 11:54:43.667298936 +0100 +++ /work/SRC/openSUSE:Factory/.kubic-control.new.6675/kubic-control.changes 2020-01-13 22:15:57.318363241 +0100 @@ -1,0 +2,6 @@ +Sun Jan 5 16:56:34 UTC 2020 - Thorsten Kukuk <[email protected]> + +- Update to version 0.9.1 + - Add support to deploy metallb and hello-kubic via kustomize + +------------------------------------------------------------------- Old: ---- kubic-control-0.9.0.tar.xz New: ---- kubic-control-0.9.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kubic-control.spec ++++++ --- /var/tmp/diff_new_pack.OSk2Ab/_old 2020-01-13 22:15:58.718363890 +0100 +++ /var/tmp/diff_new_pack.OSk2Ab/_new 2020-01-13 22:15:58.722363893 +0100 @@ -1,7 +1,7 @@ # # spec file for package kubic-control # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: kubic-control -Version: 0.9.0 +Version: 0.9.1 Release: 0 Summary: Simple setup tool for kubernetes License: Apache-2.0 @@ -37,8 +37,11 @@ Requires: cilium-k8s-yaml Requires: etcdctl Requires: flannel-k8s-yaml +Requires: hello-kubic-k8s-yaml >= 1.3 Requires: kubicctl Requires: kured-k8s-yaml +Requires: kustomize +Requires: metallb-k8s-yaml >= 0.8.3 Requires: salt-master Requires: weave-k8s-yaml ++++++ kubic-control-0.9.0.tar.xz -> kubic-control-0.9.1.tar.xz ++++++ Binary files old/kubic-control-0.9.0/.git/index and new/kubic-control-0.9.1/.git/index differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/.git/logs/HEAD new/kubic-control-0.9.1/.git/logs/HEAD --- old/kubic-control-0.9.0/.git/logs/HEAD 2019-10-05 09:58:02.975729172 +0200 +++ new/kubic-control-0.9.1/.git/logs/HEAD 2020-01-05 17:46:17.367568009 +0100 @@ -1 +1 @@ -0000000000000000000000000000000000000000 87cf653bfc5a24ca74f10115c54e2e58982d062a Thorsten Kukuk <[email protected]> 1570262282 +0200 clone: from https://github.com/thkukuk/kubic-control +0000000000000000000000000000000000000000 a4997d97bbff4fdc1fd6a940aa7e179e68214e7c Thorsten Kukuk <[email protected]> 1578242777 +0100 clone: from https://github.com/thkukuk/kubic-control diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/.git/logs/refs/heads/master new/kubic-control-0.9.1/.git/logs/refs/heads/master --- old/kubic-control-0.9.0/.git/logs/refs/heads/master 2019-10-05 09:58:02.975729172 +0200 +++ new/kubic-control-0.9.1/.git/logs/refs/heads/master 2020-01-05 17:46:17.367568009 +0100 @@ -1 +1 @@ -0000000000000000000000000000000000000000 87cf653bfc5a24ca74f10115c54e2e58982d062a Thorsten Kukuk <[email protected]> 1570262282 +0200 clone: from https://github.com/thkukuk/kubic-control +0000000000000000000000000000000000000000 a4997d97bbff4fdc1fd6a940aa7e179e68214e7c Thorsten Kukuk <[email protected]> 1578242777 +0100 clone: from https://github.com/thkukuk/kubic-control diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/.git/logs/refs/remotes/origin/HEAD new/kubic-control-0.9.1/.git/logs/refs/remotes/origin/HEAD --- old/kubic-control-0.9.0/.git/logs/refs/remotes/origin/HEAD 2019-10-05 09:58:02.975729172 +0200 +++ new/kubic-control-0.9.1/.git/logs/refs/remotes/origin/HEAD 2020-01-05 17:46:17.367568009 +0100 @@ -1 +1 @@ -0000000000000000000000000000000000000000 87cf653bfc5a24ca74f10115c54e2e58982d062a Thorsten Kukuk <[email protected]> 1570262282 +0200 clone: from https://github.com/thkukuk/kubic-control +0000000000000000000000000000000000000000 a4997d97bbff4fdc1fd6a940aa7e179e68214e7c Thorsten Kukuk <[email protected]> 1578242777 +0100 clone: from https://github.com/thkukuk/kubic-control Binary files old/kubic-control-0.9.0/.git/objects/pack/pack-81136ebb503fffa01e8e09cc09987007b39a9ce7.idx and new/kubic-control-0.9.1/.git/objects/pack/pack-81136ebb503fffa01e8e09cc09987007b39a9ce7.idx differ Binary files old/kubic-control-0.9.0/.git/objects/pack/pack-81136ebb503fffa01e8e09cc09987007b39a9ce7.pack and new/kubic-control-0.9.1/.git/objects/pack/pack-81136ebb503fffa01e8e09cc09987007b39a9ce7.pack differ Binary files old/kubic-control-0.9.0/.git/objects/pack/pack-97fc7e0ac0496877263bba315be9b65af52244c9.idx and new/kubic-control-0.9.1/.git/objects/pack/pack-97fc7e0ac0496877263bba315be9b65af52244c9.idx differ Binary files old/kubic-control-0.9.0/.git/objects/pack/pack-97fc7e0ac0496877263bba315be9b65af52244c9.pack and new/kubic-control-0.9.1/.git/objects/pack/pack-97fc7e0ac0496877263bba315be9b65af52244c9.pack differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/.git/packed-refs new/kubic-control-0.9.1/.git/packed-refs --- old/kubic-control-0.9.0/.git/packed-refs 2019-10-05 09:58:02.975729172 +0200 +++ new/kubic-control-0.9.1/.git/packed-refs 2020-01-05 17:46:17.367568009 +0100 @@ -1,5 +1,5 @@ # pack-refs with: peeled fully-peeled sorted -87cf653bfc5a24ca74f10115c54e2e58982d062a refs/remotes/origin/master +a4997d97bbff4fdc1fd6a940aa7e179e68214e7c refs/remotes/origin/master b5d6fc06c3bc9a1a242ad8263a3d8e71eadf5521 refs/tags/0.7.0 11f0daf7e39c6c8ca826819b9fa230952c167fc4 refs/tags/v0.1.0 02cfb06685013a9b6a38b31ab421c3b37f3ae3cb refs/tags/v0.2.0 @@ -16,3 +16,4 @@ 783ab0cb55f38e97e1ce0920b09a95bd45c2f2a9 refs/tags/v0.8.0 831e6b797c79846f936c99841e13061ff3600c43 refs/tags/v0.8.1 d712f15dfe3c794bdf15b22806edf66792af6ea0 refs/tags/v0.8.2 +87cf653bfc5a24ca74f10115c54e2e58982d062a refs/tags/v0.9.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/.git/refs/heads/master new/kubic-control-0.9.1/.git/refs/heads/master --- old/kubic-control-0.9.0/.git/refs/heads/master 2019-10-05 09:58:02.975729172 +0200 +++ new/kubic-control-0.9.1/.git/refs/heads/master 2020-01-05 17:46:17.367568009 +0100 @@ -1 +1 @@ -87cf653bfc5a24ca74f10115c54e2e58982d062a +a4997d97bbff4fdc1fd6a940aa7e179e68214e7c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/README.md new/kubic-control-0.9.1/README.md --- old/kubic-control-0.9.0/README.md 2019-10-05 09:58:02.979729172 +0200 +++ new/kubic-control-0.9.1/README.md 2020-01-05 17:46:17.371568027 +0100 @@ -133,6 +133,15 @@ `/usr/etc/kubicd/rbac.conf`. Changed entries should be written to `/etc/kubicd/rbac.conf`. +`Kubicctl` reads optional a `~/config/kubicctl/kubicctl.conf`, which +allows to configure to the hostname and port of a remote `kubicd` process: + +``` + [global] + server = remote.host.name + port = 7148 +``` + ## RBAC `rbac.conf` contains the roles as key and the users, who are allowed to use diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/api/api.pb.go new/kubic-control-0.9.1/api/api.pb.go --- old/kubic-control-0.9.0/api/api.pb.go 2019-10-05 09:58:03.083729169 +0200 +++ new/kubic-control-0.9.1/api/api.pb.go 2020-01-05 17:46:17.451568384 +0100 @@ -37,7 +37,7 @@ func (m *StatusReply) String() string { return proto.CompactTextString(m) } func (*StatusReply) ProtoMessage() {} func (*StatusReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{0} + return fileDescriptor_api_87a62f0460b3d7ca, []int{0} } func (m *StatusReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatusReply.Unmarshal(m, b) @@ -86,7 +86,7 @@ func (m *ListReply) String() string { return proto.CompactTextString(m) } func (*ListReply) ProtoMessage() {} func (*ListReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{1} + return fileDescriptor_api_87a62f0460b3d7ca, []int{1} } func (m *ListReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ListReply.Unmarshal(m, b) @@ -147,7 +147,7 @@ func (m *InitRequest) String() string { return proto.CompactTextString(m) } func (*InitRequest) ProtoMessage() {} func (*InitRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{2} + return fileDescriptor_api_87a62f0460b3d7ca, []int{2} } func (m *InitRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InitRequest.Unmarshal(m, b) @@ -221,7 +221,7 @@ func (m *UpgradeRequest) String() string { return proto.CompactTextString(m) } func (*UpgradeRequest) ProtoMessage() {} func (*UpgradeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{3} + return fileDescriptor_api_87a62f0460b3d7ca, []int{3} } func (m *UpgradeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpgradeRequest.Unmarshal(m, b) @@ -262,7 +262,7 @@ func (m *AddNodeRequest) String() string { return proto.CompactTextString(m) } func (*AddNodeRequest) ProtoMessage() {} func (*AddNodeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{4} + return fileDescriptor_api_87a62f0460b3d7ca, []int{4} } func (m *AddNodeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AddNodeRequest.Unmarshal(m, b) @@ -308,7 +308,7 @@ func (m *RemoveNodeRequest) String() string { return proto.CompactTextString(m) } func (*RemoveNodeRequest) ProtoMessage() {} func (*RemoveNodeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{5} + return fileDescriptor_api_87a62f0460b3d7ca, []int{5} } func (m *RemoveNodeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RemoveNodeRequest.Unmarshal(m, b) @@ -347,7 +347,7 @@ func (m *RebootNodeRequest) String() string { return proto.CompactTextString(m) } func (*RebootNodeRequest) ProtoMessage() {} func (*RebootNodeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{6} + return fileDescriptor_api_87a62f0460b3d7ca, []int{6} } func (m *RebootNodeRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RebootNodeRequest.Unmarshal(m, b) @@ -385,7 +385,7 @@ func (m *Version) String() string { return proto.CompactTextString(m) } func (*Version) ProtoMessage() {} func (*Version) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{7} + return fileDescriptor_api_87a62f0460b3d7ca, []int{7} } func (m *Version) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Version.Unmarshal(m, b) @@ -422,7 +422,7 @@ func (m *Empty) String() string { return proto.CompactTextString(m) } func (*Empty) ProtoMessage() {} func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{8} + return fileDescriptor_api_87a62f0460b3d7ca, []int{8} } func (m *Empty) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Empty.Unmarshal(m, b) @@ -453,7 +453,7 @@ func (m *CreateCertRequest) String() string { return proto.CompactTextString(m) } func (*CreateCertRequest) ProtoMessage() {} func (*CreateCertRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{9} + return fileDescriptor_api_87a62f0460b3d7ca, []int{9} } func (m *CreateCertRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateCertRequest.Unmarshal(m, b) @@ -496,7 +496,7 @@ func (m *CertificateReply) String() string { return proto.CompactTextString(m) } func (*CertificateReply) ProtoMessage() {} func (*CertificateReply) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{10} + return fileDescriptor_api_87a62f0460b3d7ca, []int{10} } func (m *CertificateReply) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CertificateReply.Unmarshal(m, b) @@ -544,6 +544,52 @@ return "" } +type DeployKustomizeRequest struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` + Argument string `protobuf:"bytes,2,opt,name=argument,proto3" json:"argument,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeployKustomizeRequest) Reset() { *m = DeployKustomizeRequest{} } +func (m *DeployKustomizeRequest) String() string { return proto.CompactTextString(m) } +func (*DeployKustomizeRequest) ProtoMessage() {} +func (*DeployKustomizeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_api_87a62f0460b3d7ca, []int{11} +} +func (m *DeployKustomizeRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeployKustomizeRequest.Unmarshal(m, b) +} +func (m *DeployKustomizeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeployKustomizeRequest.Marshal(b, m, deterministic) +} +func (dst *DeployKustomizeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeployKustomizeRequest.Merge(dst, src) +} +func (m *DeployKustomizeRequest) XXX_Size() int { + return xxx_messageInfo_DeployKustomizeRequest.Size(m) +} +func (m *DeployKustomizeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeployKustomizeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeployKustomizeRequest proto.InternalMessageInfo + +func (m *DeployKustomizeRequest) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func (m *DeployKustomizeRequest) GetArgument() string { + if m != nil { + return m.Argument + } + return "" +} + type PrepareConfigRequest struct { Saltnode string `protobuf:"bytes,1,opt,name=saltnode,proto3" json:"saltnode,omitempty"` Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` @@ -562,7 +608,7 @@ func (m *PrepareConfigRequest) String() string { return proto.CompactTextString(m) } func (*PrepareConfigRequest) ProtoMessage() {} func (*PrepareConfigRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{11} + return fileDescriptor_api_87a62f0460b3d7ca, []int{12} } func (m *PrepareConfigRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_PrepareConfigRequest.Unmarshal(m, b) @@ -642,7 +688,7 @@ func (m *InstallRequest) String() string { return proto.CompactTextString(m) } func (*InstallRequest) ProtoMessage() {} func (*InstallRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_api_14ad3452ca8e2330, []int{12} + return fileDescriptor_api_87a62f0460b3d7ca, []int{13} } func (m *InstallRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InstallRequest.Unmarshal(m, b) @@ -681,6 +727,7 @@ proto.RegisterType((*Empty)(nil), "api.Empty") proto.RegisterType((*CreateCertRequest)(nil), "api.CreateCertRequest") proto.RegisterType((*CertificateReply)(nil), "api.CertificateReply") + proto.RegisterType((*DeployKustomizeRequest)(nil), "api.DeployKustomizeRequest") proto.RegisterType((*PrepareConfigRequest)(nil), "api.PrepareConfigRequest") proto.RegisterType((*InstallRequest)(nil), "api.InstallRequest") } @@ -1258,6 +1305,70 @@ Metadata: "api.proto", } +// DeployClient is the client API for Deploy service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DeployClient interface { + DeployKustomize(ctx context.Context, in *DeployKustomizeRequest, opts ...grpc.CallOption) (*StatusReply, error) +} + +type deployClient struct { + cc *grpc.ClientConn +} + +func NewDeployClient(cc *grpc.ClientConn) DeployClient { + return &deployClient{cc} +} + +func (c *deployClient) DeployKustomize(ctx context.Context, in *DeployKustomizeRequest, opts ...grpc.CallOption) (*StatusReply, error) { + out := new(StatusReply) + err := c.cc.Invoke(ctx, "/api.Deploy/DeployKustomize", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DeployServer is the server API for Deploy service. +type DeployServer interface { + DeployKustomize(context.Context, *DeployKustomizeRequest) (*StatusReply, error) +} + +func RegisterDeployServer(s *grpc.Server, srv DeployServer) { + s.RegisterService(&_Deploy_serviceDesc, srv) +} + +func _Deploy_DeployKustomize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeployKustomizeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DeployServer).DeployKustomize(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Deploy/DeployKustomize", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DeployServer).DeployKustomize(ctx, req.(*DeployKustomizeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Deploy_serviceDesc = grpc.ServiceDesc{ + ServiceName: "api.Deploy", + HandlerType: (*DeployServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "DeployKustomize", + Handler: _Deploy_DeployKustomize_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api.proto", +} + // YomiClient is the client API for Yomi service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. @@ -1409,52 +1520,56 @@ Metadata: "api.proto", } -func init() { proto.RegisterFile("api.proto", fileDescriptor_api_14ad3452ca8e2330) } +func init() { proto.RegisterFile("api.proto", fileDescriptor_api_87a62f0460b3d7ca) } -var fileDescriptor_api_14ad3452ca8e2330 = []byte{ - // 703 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x6e, 0x13, 0x3b, - 0x10, 0x6e, 0x4e, 0xda, 0x6e, 0x77, 0x72, 0x9a, 0xd3, 0xf8, 0xf4, 0x1c, 0x6d, 0x23, 0x10, 0xc5, - 0x08, 0x51, 0x24, 0x5a, 0xd1, 0xd0, 0x0b, 0x84, 0xc4, 0x4f, 0x15, 0x7e, 0x54, 0xb5, 0x54, 0x68, - 0xab, 0x22, 0x71, 0x15, 0x39, 0xf1, 0x34, 0x5d, 0x92, 0x5d, 0x2f, 0xb6, 0x37, 0x90, 0x1b, 0x5e, - 0x8d, 0x67, 0xe0, 0x39, 0x78, 0x09, 0x64, 0xaf, 0x37, 0x3f, 0x6d, 0xa2, 0x96, 0x5e, 0xed, 0xcc, - 0xe7, 0xf9, 0xec, 0xf1, 0xf8, 0x9b, 0x59, 0xf0, 0x59, 0x1a, 0xed, 0xa4, 0x52, 0x68, 0x41, 0xca, - 0x2c, 0x8d, 0xe8, 0x3e, 0x54, 0x4e, 0x34, 0xd3, 0x99, 0x0a, 0x31, 0xed, 0x0f, 0x49, 0x00, 0x9e, - 0xca, 0x3a, 0x1d, 0x54, 0x2a, 0x28, 0x6d, 0x96, 0xb6, 0x56, 0xc2, 0xc2, 0x35, 0x2b, 0x31, 0x2a, - 0xc5, 0xba, 0x18, 0xfc, 0xb5, 0x59, 0xda, 0xf2, 0xc3, 0xc2, 0xa5, 0x27, 0xe0, 0x1f, 0x45, 0x4a, - 0xdf, 0x78, 0x03, 0x42, 0x60, 0x31, 0x11, 0x1c, 0x83, 0xf2, 0x66, 0x79, 0xcb, 0x0f, 0xad, 0x4d, - 0x7f, 0x96, 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73, - 0x0a, 0x25, 0xff, 0xda, 0x80, 0x69, 0xbd, 0xce, 0x61, 0x3d, 0x03, 0x18, 0x4b, 0x92, 0xfc, 0x6f, - 0x63, 0x2e, 0x69, 0x74, 0x0e, 0xf7, 0xa9, 0xe1, 0x16, 0xd2, 0x1c, 0x71, 0x2f, 0x68, 0x75, 0x16, - 0x97, 0x3c, 0xcc, 0xe7, 0x96, 0x09, 0x53, 0x04, 0x6c, 0x80, 0xd5, 0x62, 0xbd, 0x6a, 0xed, 0xd1, - 0x4c, 0xa3, 0x0b, 0x64, 0x17, 0x56, 0x5f, 0xa3, 0xd2, 0x52, 0x0c, 0x5d, 0x3d, 0x26, 0xc3, 0x67, - 0xe7, 0xf5, 0x02, 0x6a, 0xae, 0xd9, 0x0f, 0x47, 0x7d, 0xec, 0x6a, 0x32, 0x3d, 0x04, 0xe6, 0xf0, - 0x77, 0xe1, 0x9f, 0xb7, 0xa8, 0x3b, 0xe7, 0x86, 0xdd, 0xb1, 0xe2, 0xbb, 0xea, 0x50, 0xb2, 0x0d, - 0xfe, 0x3b, 0xd4, 0x39, 0x76, 0x75, 0x86, 0x8d, 0x23, 0xa8, 0x4c, 0x74, 0x12, 0x79, 0x0e, 0x30, - 0xee, 0x40, 0x57, 0xc8, 0x4b, 0x2d, 0x59, 0xff, 0x2f, 0xc7, 0x2f, 0x74, 0x20, 0x5d, 0x68, 0x7c, - 0x87, 0xc5, 0x4f, 0x22, 0x8e, 0xc8, 0x2b, 0x58, 0x9d, 0x6a, 0x19, 0xb2, 0x61, 0x19, 0xb3, 0xda, - 0x68, 0xbe, 0x86, 0x9c, 0x66, 0x5d, 0xbd, 0xa6, 0x15, 0x3c, 0x9b, 0xd5, 0x5e, 0xb6, 0x3f, 0xb5, - 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x44, 0x1c, 0xac, 0x6a, 0xe1, 0x06, 0x00, 0x00, +var fileDescriptor_api_87a62f0460b3d7ca = []byte{ + // 763 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xef, 0x4e, 0x1b, 0x39, + 0x10, 0x27, 0x17, 0x20, 0xd9, 0xc9, 0x11, 0x88, 0x8f, 0x43, 0x4b, 0xee, 0x4e, 0xc7, 0xed, 0xa9, + 0x2a, 0x95, 0x0a, 0x2a, 0x29, 0x1f, 0xaa, 0x4a, 0xfd, 0x43, 0x43, 0x5b, 0x21, 0x68, 0x54, 0x2d, + 0xa2, 0x52, 0x3f, 0x45, 0x4e, 0x76, 0x08, 0x6e, 0xb2, 0xeb, 0xad, 0xed, 0x4d, 0x9b, 0x7e, 0xe8, + 0xab, 0xf5, 0x19, 0xfa, 0x1c, 0x7d, 0x89, 0xca, 0x5e, 0xef, 0x26, 0x81, 0x44, 0x50, 0x3e, 0xed, + 0xcc, 0xcf, 0xf3, 0xb3, 0xc7, 0xe3, 0xf9, 0xcd, 0x82, 0x43, 0x63, 0xb6, 0x1b, 0x0b, 0xae, 0x38, + 0x29, 0xd2, 0x98, 0x79, 0x07, 0x50, 0x39, 0x55, 0x54, 0x25, 0xd2, 0xc7, 0x78, 0x30, 0x22, 0x2e, + 0x94, 0x64, 0xd2, 0xed, 0xa2, 0x94, 0x6e, 0x61, 0xab, 0xb0, 0x5d, 0xf6, 0x33, 0x57, 0xaf, 0x84, + 0x28, 0x25, 0xed, 0xa1, 0xfb, 0xdb, 0x56, 0x61, 0xdb, 0xf1, 0x33, 0xd7, 0x3b, 0x05, 0xe7, 0x84, + 0x49, 0x75, 0xeb, 0x0d, 0x08, 0x81, 0xc5, 0x88, 0x07, 0xe8, 0x16, 0xb7, 0x8a, 0xdb, 0x8e, 0x6f, + 0x6c, 0xef, 0x7b, 0x01, 0x2a, 0x47, 0x11, 0x53, 0x3e, 0x7e, 0x4c, 0x50, 0x2a, 0xb2, 0x03, 0xa4, + 0x9f, 0x74, 0x50, 0x44, 0xa8, 0x50, 0xb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0x89, 0x72, 0x7e, 0x47, 0x5a, + 0x05, 0xd8, 0xea, 0x4f, 0xeb, 0x61, 0x36, 0xab, 0xb3, 0x6c, 0x7e, 0xb9, 0x0f, 0x7f, 0x06, 0x00, + 0x00, 0xff, 0xff, 0x1b, 0x97, 0x90, 0xef, 0x7f, 0x07, 0x00, 0x00, } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/api/api.proto new/kubic-control-0.9.1/api/api.proto --- old/kubic-control-0.9.0/api/api.proto 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/api/api.proto 2020-01-05 17:46:17.371568027 +0100 @@ -109,6 +109,16 @@ string crt = 4; } +// Deploy services/... +service Deploy { + rpc DeployKustomize (DeployKustomizeRequest) returns (StatusReply) {} +} + +message DeployKustomizeRequest { + string service = 1; + string argument = 2; +} + // Install Node with yomi service Yomi { rpc PrepareConfig (PrepareConfigRequest) returns (stream StatusReply) {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/cmd/kubicd/main.go new/kubic-control-0.9.1/cmd/kubicd/main.go --- old/kubic-control-0.9.0/cmd/kubicd/main.go 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/cmd/kubicd/main.go 2020-01-05 17:46:17.375568044 +0100 @@ -33,6 +33,7 @@ "github.com/spf13/cobra" log "github.com/sirupsen/logrus" "github.com/thkukuk/kubic-control/pkg/kubeadm" + "github.com/thkukuk/kubic-control/pkg/deployment" "github.com/thkukuk/kubic-control/pkg/certificate_server" "github.com/thkukuk/kubic-control/pkg/yomi" pb "github.com/thkukuk/kubic-control/api" @@ -49,6 +50,7 @@ ) type kubeadm_server struct{} +type deploy_server struct{} type cert_server struct{} type yomi_server struct{} @@ -108,6 +110,13 @@ return &pb.CertificateReply{Success: status, Message: message, Key: key, Crt: crt}, nil } +// Deploy API +func (s *deploy_server) DeployKustomize(ctx context.Context, in *pb.DeployKustomizeRequest) (*pb.StatusReply, error) { + log.Printf("Received: deploy kustomized service %s", in.Service) + status, message := deployment.DeployKustomize(in.Service, in.Argument) + return &pb.StatusReply{Success: status, Message: message}, nil +} + // Yomi API func (s *yomi_server) PrepareConfig(in *pb.PrepareConfigRequest, stream pb.Yomi_PrepareConfigServer) error { log.Infof("Received: PrepareConfig of %s for Node %s", in.Saltnode, in.Type) @@ -299,6 +308,7 @@ grpc.UnaryInterceptor(AuthUnaryInterceptor)) pb.RegisterKubeadmServer(s, &kubeadm_server{}) + pb.RegisterDeployServer(s, &deploy_server{}) pb.RegisterCertificateServer(s, &cert_server{}) pb.RegisterYomiServer(s, &yomi_server{}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/etc/kubicd/rbac.conf new/kubic-control-0.9.1/etc/kubicd/rbac.conf --- old/kubic-control-0.9.0/etc/kubicd/rbac.conf 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/etc/kubicd/rbac.conf 2020-01-05 17:46:17.375568044 +0100 @@ -8,5 +8,6 @@ Kubeadm/DestroyMaster=admin Kubeadm/GetStatus=admin Certificate/CreateCert=admin +Deploy/DeployKustomize=admin Yomi/PrepareConfig=admin Yomi/Install=admin diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/deploy.go new/kubic-control-0.9.1/pkg/deployment/deploy.go --- old/kubic-control-0.9.0/pkg/deployment/deploy.go 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/pkg/deployment/deploy.go 1970-01-01 01:00:00.000000000 +0100 @@ -1,44 +0,0 @@ -// Copyright 2019 Thorsten Kukuk -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package deployment - -import ( - "gopkg.in/ini.v1" - "github.com/thkukuk/kubic-control/pkg/tools" -) - -func DeployFile(yamlName string) (bool, string) { - - success, message := tools.ExecuteCmd("kubectl", "--kubeconfig=/etc/kubernetes/admin.conf", - "apply", "-f", yamlName) - if success != true { - return success, message - } - - result, err := tools.Sha256sum(yamlName) - - cfg, err := ini.LooseLoad("/var/lib/kubic-control/k8s-yaml.conf") - if err != nil { - return false, "Cannot load k8s-yaml.conf: " + err.Error() - } - - cfg.Section("").Key(yamlName).SetValue(result) - err = cfg.SaveTo("/var/lib/kubic-control/k8s-yaml.conf") - if err != nil { - return false, "Cannot write k8s-yaml.conf: " + err.Error() - } - - return true, "" -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/deployFile.go new/kubic-control-0.9.1/pkg/deployment/deployFile.go --- old/kubic-control-0.9.0/pkg/deployment/deployFile.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/deployment/deployFile.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,44 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package deployment + +import ( + "gopkg.in/ini.v1" + "github.com/thkukuk/kubic-control/pkg/tools" +) + +func DeployFile(yamlName string) (bool, string) { + + success, message := tools.ExecuteCmd("kubectl", "--kubeconfig=/etc/kubernetes/admin.conf", + "apply", "-f", yamlName) + if success != true { + return success, message + } + + result, err := tools.Sha256sum_f(yamlName) + + cfg, err := ini.LooseLoad("/var/lib/kubic-control/k8s-yaml.conf") + if err != nil { + return false, "Cannot load k8s-yaml.conf: " + err.Error() + } + + cfg.Section("").Key(yamlName).SetValue(result) + err = cfg.SaveTo("/var/lib/kubic-control/k8s-yaml.conf") + if err != nil { + return false, "Cannot write k8s-yaml.conf: " + err.Error() + } + + return true, "" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/deployKustomize.go new/kubic-control-0.9.1/pkg/deployment/deployKustomize.go --- old/kubic-control-0.9.0/pkg/deployment/deployKustomize.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/deployment/deployKustomize.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,181 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package deployment + +import ( + "strings" + "os" + + "gopkg.in/ini.v1" + "github.com/thkukuk/kubic-control/pkg/tools" +) + +const ( + StateDir = "/var/lib/kubic-control" +) + +func setupMetalLB(iprange string) (bool, string) { + + f, err := os.Create(StateDir + "/kustomize/metallb/overlay/kustomization.yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + + _, err = f.WriteString("resources:\n - ../base\n - layer2-config.yaml") + if err != nil { + return false, err.Error() + } + f.Close() + + f, err = os.Create(StateDir + "/kustomize/metallb/overlay/layer2-config.yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + + _, err = f.WriteString("apiVersion: v1\nkind: ConfigMap\nmetadata:\n namespace: metallb-system\n name: config\ndata:\n config: |\n address-pools:\n - name: my-ip-space\n protocol: layer2\n addresses:\n - " + iprange) + if err != nil { + return false, err.Error() + } + f.Close() + + return true, "" +} + +func setupHelloKubic(arg string) (bool, string) { + + f, err := os.Create(StateDir + "/kustomize/hello-kubic/overlay/kustomization.yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + + if strings.EqualFold(arg, "NodePort") { + // Use NodePort to make the service available + _, err = f.WriteString("resources:\n - ../base\npatchesStrategicMerge:\n - patch_NodePort.yaml") + if err != nil { + return false, err.Error() + } + f.Close() + + f, err = os.Create(StateDir + "/kustomize/hello-kubic/overlay/patch_NodePort.yaml") + if err != nil { + return false, err.Error() + } + _, err = f.WriteString("apiVersion: v1\nkind: Service\nmetadata:\n name: hello-kubic\nspec:\n type: NodePort") + if err != nil { + return false, err.Error() + } + f.Close() + } else if strings.EqualFold(arg, "LoadBalancer") { + // LoadBalancer without prefered IP + _, err = f.WriteString("resources:\n - ../base") + if err != nil { + return false, err.Error() + } + f.Close() + } else { + // LoadBalancer with prefered IP + _, err = f.WriteString("resources:\n - ../base\npatchesStrategicMerge:\n - patch_LoadBalancerIP.yaml") + if err != nil { + return false, err.Error() + } + f.Close() + + f, err = os.Create(StateDir + "/kustomize/hello-kubic/overlay/patch_loadBalancerIP.yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + + _, err = f.WriteString("apiVersion: v1\nkind: Service\nmetadata:\n name: hello-kubic\nspec:\n loadBalancerIP: " + arg) + if err != nil { + return false, err.Error() + } + f.Close() + } + + return true, "" +} + +func DeployKustomize(service string, argument string) (bool, string) { + + os.RemoveAll(StateDir + "/kustomize/" + service) + err := os.MkdirAll(StateDir + "/kustomize/" + service + "/overlay", + os.ModePerm) + if err != nil { + return false, "Cannot create " + StateDir + "/kustomize/" + service + "/overlay: " + err.Error() + } + err = os.Symlink("/usr/share/k8s-yaml/" +service, + StateDir + "/kustomize/"+ service + "/base") + if err != nil { + return false, "Cannot link " + service + + " base directory: " + err.Error() + } + + switch service { + case "metallb": + retval, message := setupMetalLB(argument) + if retval != true { + os.RemoveAll(StateDir + "/kustomize/" + service) + return false, message + } + case "hello-kubic": + retval, message := setupHelloKubic(argument) + if retval != true { + os.RemoveAll(StateDir + "/kustomize/" + service) + return false, message + } + } + retval, message := tools.ExecuteCmd("kustomize", "build", + StateDir + "/kustomize/" + service + "/overlay") + if retval != true { + os.RemoveAll(StateDir + "/kustomize/" + service) + return false, message + } + + f, err := os.Create(StateDir + "/kustomize/" + service + "/" + service + ".yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + _, err = f.WriteString(message) + if err != nil { + return false, err.Error() + } + f.Close() + + result, err := tools.Sha256sum_f(StateDir + "/kustomize/" + service + "/" + service + ".yaml"); + retval, message = tools.ExecuteCmd("kubectl", + "--kubeconfig=/etc/kubernetes/admin.conf", "apply", "-f", + StateDir + "/kustomize/" + service + "/" + service + ".yaml") + if retval != true { + return false, message + } + + cfg, err := ini.LooseLoad(StateDir + "/k8s-kustomize.conf") + if err != nil { + return false, "Cannot load k8s-kustomize.conf: " + err.Error() + } + + cfg.Section("").Key(service).SetValue(result) + err = cfg.SaveTo(StateDir + "/k8s-kustomize.conf") + if err != nil { + return false, "Cannot write k8s-kustomize.conf: " + err.Error() + } + + return true, "" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/update.go new/kubic-control-0.9.1/pkg/deployment/update.go --- old/kubic-control-0.9.0/pkg/deployment/update.go 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/pkg/deployment/update.go 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -// Copyright 2019 Thorsten Kukuk -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package deployment - -import ( - "gopkg.in/ini.v1" - "github.com/thkukuk/kubic-control/pkg/tools" -) - -func UpdateFile(yamlName string) (bool, string) { - - success, message := tools.ExecuteCmd("kubectl", - "--kubeconfig=/etc/kubernetes/admin.conf", - "apply", "-f", yamlName) - if success != true { - return success, message - } - - result, err := tools.Sha256sum(yamlName) - - cfg, err := ini.LooseLoad("/var/lib/kubic-control/k8s-yaml.conf") - if err != nil { - return false, "Cannot load k8s-yaml.conf: " + err.Error() - } - - cfg.Section("").Key(yamlName).SetValue(result) - err = cfg.SaveTo("/var/lib/kubic-control/k8s-yaml.conf") - if err != nil { - return false, "Cannot write k8s-yaml.conf: " + err.Error() - } - - return true, "" -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/updateAll.go new/kubic-control-0.9.1/pkg/deployment/updateAll.go --- old/kubic-control-0.9.0/pkg/deployment/updateAll.go 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/pkg/deployment/updateAll.go 2020-01-05 17:46:17.375568044 +0100 @@ -1,4 +1,4 @@ -// Copyright 2019 Thorsten Kukuk +// Copyright 2019, 2020 Thorsten Kukuk // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ } } else { value := cfg.Section("").Key(key).String() - hash, _ := tools.Sha256sum(key) + hash, _ := tools.Sha256sum_f(key) if hash != value { log.Infof("%s has changed, updating") @@ -45,6 +45,43 @@ if success != true { return success, message } + } else { + log.Infof("%s has not changed, ignoring") + } + } + } + + + // Update kustomize installed services + cfg, err = ini.Load("/var/lib/kubic-control/k8s-kustomize.conf") + if err != nil { + return false, "Cannot load k8s-kustomize.conf: " + err.Error() + } + + keys = cfg.Section("").KeyStrings() + for _, key := range keys { + if forced { + // force, so always update even if not changed + success, message := UpdateKustomize(key) + if success != true { + return success, message + } + } else { + retval, message := tools.ExecuteCmd("kustomize", "build", + StateDir + "/kustomize/" + key + "/overlay") + if retval != true { + return retval, message + } + + value := cfg.Section("").Key(key).String() + hash, _ := tools.Sha256sum_f(message) + + if hash != value { + log.Infof("%s has changed, updating") + success, message := UpdateKustomize(key) + if success != true { + return success, message + } } else { log.Infof("%s has not changed, ignoring") } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/updateFile.go new/kubic-control-0.9.1/pkg/deployment/updateFile.go --- old/kubic-control-0.9.0/pkg/deployment/updateFile.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/deployment/updateFile.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,45 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package deployment + +import ( + "gopkg.in/ini.v1" + "github.com/thkukuk/kubic-control/pkg/tools" +) + +func UpdateFile(yamlName string) (bool, string) { + + success, message := tools.ExecuteCmd("kubectl", + "--kubeconfig=/etc/kubernetes/admin.conf", + "apply", "-f", yamlName) + if success != true { + return success, message + } + + result, err := tools.Sha256sum_f(yamlName) + + cfg, err := ini.LooseLoad("/var/lib/kubic-control/k8s-yaml.conf") + if err != nil { + return false, "Cannot load k8s-yaml.conf: " + err.Error() + } + + cfg.Section("").Key(yamlName).SetValue(result) + err = cfg.SaveTo("/var/lib/kubic-control/k8s-yaml.conf") + if err != nil { + return false, "Cannot write k8s-yaml.conf: " + err.Error() + } + + return true, "" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/deployment/updateKustomize.go new/kubic-control-0.9.1/pkg/deployment/updateKustomize.go --- old/kubic-control-0.9.0/pkg/deployment/updateKustomize.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/deployment/updateKustomize.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,63 @@ +// Copyright 2020 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package deployment + +import ( + "os" + + "gopkg.in/ini.v1" + "github.com/thkukuk/kubic-control/pkg/tools" +) + +func UpdateKustomize(service string) (bool, string) { + + retval, message := tools.ExecuteCmd("kustomize", "build", + StateDir + "/kustomize/" + service + "/overlay") + if retval != true { + return false, message + } + + f, err := os.Create(StateDir + "/kustomize/" + service + "/" + service + ".yaml") + if err != nil { + return false, err.Error() + } + defer f.Close() + _, err = f.WriteString(message) + if err != nil { + return false, err.Error() + } + f.Close() + + retval, message = tools.ExecuteCmd("kubectl", + "--kubeconfig=/etc/kubernetes/admin.conf", "apply", "-f", + StateDir + "/kustomize/" + service + "/" + service + ".yaml") + if retval != true { + return false, message + } + + cfg, err := ini.LooseLoad(StateDir + "/k8s-kustomize.conf") + if err != nil { + return false, "Cannot load k8s-kustomize.conf: " + err.Error() + } + + result, err := tools.Sha256sum_f(StateDir + "/kustomize/" + service + "/" + service + ".yaml"); + cfg.Section("").Key(service).SetValue(result) + err = cfg.SaveTo(StateDir + "/k8s-kustomize.conf") + if err != nil { + return false, "Cannot write k8s-kustomize.conf: " + err.Error() + } + + return true, "" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubeadm/getStatus.go new/kubic-control-0.9.1/pkg/kubeadm/getStatus.go --- old/kubic-control-0.9.0/pkg/kubeadm/getStatus.go 2019-10-05 09:58:02.983729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubeadm/getStatus.go 2020-01-05 17:46:17.375568044 +0100 @@ -35,6 +35,7 @@ return err } + // Standard yaml files cfg, err := ini.Load("/var/lib/kubic-control/k8s-yaml.conf") if err != nil { if err := stream.Send(&pb.StatusReply{Success: false, @@ -48,14 +49,55 @@ if len(keys) > 0 { if err := stream.Send(&pb.StatusReply{Success: true, - Message: "Status of deployed daemonsets:"}); err != nil { + Message: "Status of deployed daemonsets (yaml):"}); err != nil { log.Errorf("Send message failed: %s", err) return err } } for _, key := range keys { value := cfg.Section("").Key(key).String() - hash, _ := tools.Sha256sum(key) + hash, _ := tools.Sha256sum_f(key) + if hash != value { + if err := stream.Send(&pb.StatusReply{Success: true, + Message: "- " + key + ": newer version available"}); err != nil { + log.Errorf("Send message failed: %s", err) + return err + } + } else { + if err := stream.Send(&pb.StatusReply{Success: true, + Message: "- " + key + ": up to date"}); err != nil { + log.Errorf("Send message failed: %s", err) + return err + } + + } + } + } + + // kustomize + cfg, err = ini.Load("/var/lib/kubic-control/k8s-kustomize.conf") + if err != nil { + if err := stream.Send(&pb.StatusReply{Success: false, + Message: "Cannot load k8s-yaml.conf: " + err.Error()}); err != nil { + log.Errorf("Send message failed: %s", err) + return err + } + } else { + + keys := cfg.Section("").KeyStrings() + + if len(keys) > 0 { + if err := stream.Send(&pb.StatusReply{Success: true, + Message: "Status of deployed daemonsets (kustomize):"}); err != nil { + log.Errorf("Send message failed: %s", err) + return err + } + } + for _, key := range keys { + value := cfg.Section("").Key(key).String() + _, output := tools.ExecuteCmd("kustomize", "build", + "/var/lib/kubic-control/kustomize/" + key + "/overlay") + hash, _ := tools.Sha256sum_b(output) if hash != value { if err := stream.Send(&pb.StatusReply{Success: true, Message: "- " + key + ": newer version available"}); err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/addNode.go new/kubic-control-0.9.1/pkg/kubicctl/addNode.go --- old/kubic-control-0.9.0/pkg/kubicctl/addNode.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/addNode.go 2020-01-05 17:46:17.375568044 +0100 @@ -56,9 +56,6 @@ client := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/createCerts.go new/kubic-control-0.9.1/pkg/kubicctl/createCerts.go --- old/kubic-control-0.9.0/pkg/kubicctl/createCerts.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/createCerts.go 2020-01-05 17:46:17.375568044 +0100 @@ -48,7 +48,7 @@ c := pb.NewCertificateClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() r, err := c.CreateCert(ctx, &pb.CreateCertRequest{Name: user}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/deploy.go new/kubic-control-0.9.1/pkg/kubicctl/deploy.go --- old/kubic-control-0.9.0/pkg/kubicctl/deploy.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/kubicctl/deploy.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,33 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kubicctl + +import ( + "github.com/spf13/cobra" +) + +func DeployCmd() *cobra.Command { + var subCmd = &cobra.Command { + Use: "deploy", + Short: "deploy new resource", + } + + subCmd.AddCommand( + DeployMetalLBCmd(), + DeployHelloKubicCmd(), + ) + + return subCmd +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/deployHelloKubic.go new/kubic-control-0.9.1/pkg/kubicctl/deployHelloKubic.go --- old/kubic-control-0.9.0/pkg/kubicctl/deployHelloKubic.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/kubicctl/deployHelloKubic.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,93 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kubicctl + +import ( + "context" + "strings" + "time" + "fmt" + "os" + "io/ioutil" + + "github.com/spf13/cobra" + pb "github.com/thkukuk/kubic-control/api" +) + +var ( + service_type = "NodePort" + arg_lbip = "" +) + +func DeployHelloKubicCmd() *cobra.Command { + var subCmd = &cobra.Command { + Use: "hello-kubic", + Short: "Deploy hello-kubic", + Run: deployHelloKubic, + Args: cobra.ExactArgs(0), + } + + subCmd.PersistentFlags().StringVarP(&service_type, "type", "t", service_type, "Type for this service: NodePort or LoadBalancer") + subCmd.PersistentFlags().StringVarP(&arg_lbip, "ip", "i", arg_lbip, "LoadBalancer IP") + + return subCmd +} + +func deployHelloKubic(cmd *cobra.Command, args []string) { + + // Set up a connection to the server. + conn, err := CreateConnection() + if err != nil { + return + } + defer conn.Close() + + c := pb.NewDeployClient(conn) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + + var arg string + + if strings.EqualFold(service_type, "NodePort") { + arg = "NodePort" + } else if strings.EqualFold(service_type, "LoadBalancer") { + arg = "LoadBalancer" + } + + r, err := c.DeployKustomize(ctx, + &pb.DeployKustomizeRequest{Service: "hello-kubic", Argument: arg}) + if err != nil { + fmt.Fprintf(os.Stderr, "Could not initialize: %v\n", err) + os.Exit(1) + } + if r.Success { + if len(output) > 0 && output != "stdout" { + message:=[]byte(r.Message) + err := ioutil.WriteFile(output, message, 0600) + if err != nil { + fmt.Fprintf(os.Stderr, + "Error writing '%s': %v\n", output, err) + os.Exit(1) + } + } else { + fmt.Printf(r.Message) + } + } else { + fmt.Fprintf(os.Stderr, "Couldn't deploy hello-kubic: %s\n", + r.Message) + os.Exit(1) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/deployMetalLB.go new/kubic-control-0.9.1/pkg/kubicctl/deployMetalLB.go --- old/kubic-control-0.9.0/pkg/kubicctl/deployMetalLB.go 1970-01-01 01:00:00.000000000 +0100 +++ new/kubic-control-0.9.1/pkg/kubicctl/deployMetalLB.go 2020-01-05 17:46:17.375568044 +0100 @@ -0,0 +1,78 @@ +// Copyright 2019 Thorsten Kukuk +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kubicctl + +import ( + "context" + "time" + "fmt" + "os" + "io/ioutil" + + "github.com/spf13/cobra" + pb "github.com/thkukuk/kubic-control/api" +) + +func DeployMetalLBCmd() *cobra.Command { + var subCmd = &cobra.Command { + Use: "metallb <ip range>", + Short: "Deploy MetalLB", + Run: deployMetalLB, + Args: cobra.ExactArgs(1), + } + + return subCmd +} + +func deployMetalLB(cmd *cobra.Command, args []string) { + + iprange := args[0] + + // Set up a connection to the server. + conn, err := CreateConnection() + if err != nil { + return + } + defer conn.Close() + + c := pb.NewDeployClient(conn) + + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + + r, err := c.DeployKustomize(ctx, + &pb.DeployKustomizeRequest{Service: "metallb", Argument: iprange}) + if err != nil { + fmt.Fprintf(os.Stderr, "Could not initialize: %v\n", err) + os.Exit(1) + } + if r.Success { + if len(output) > 0 && output != "stdout" { + message:=[]byte(r.Message) + err := ioutil.WriteFile(output, message, 0600) + if err != nil { + fmt.Fprintf(os.Stderr, + "Error writing '%s': %v\n", output, err) + os.Exit(1) + } + } else { + fmt.Printf(r.Message) + } + } else { + fmt.Fprintf(os.Stderr, "Couldn't deploy metallb: %s\n", + r.Message) + os.Exit(1) + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/destroyCluster.go new/kubic-control-0.9.1/pkg/kubicctl/destroyCluster.go --- old/kubic-control-0.9.0/pkg/kubicctl/destroyCluster.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/destroyCluster.go 2020-01-05 17:46:17.375568044 +0100 @@ -47,10 +47,7 @@ client := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() stream, err := client.RemoveNode(ctx, &pb.RemoveNodeRequest{NodeNames: "*"}) @@ -81,10 +78,7 @@ fmt.Printf("All nodes removed, removing master...\n") - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - ctx, cancel = context.WithTimeout(context.Background(), time.Minute) + ctx, cancel = context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() stream, err = client.DestroyMaster(ctx, &pb.Empty{}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/fetchKubeconfig.go new/kubic-control-0.9.1/pkg/kubicctl/fetchKubeconfig.go --- old/kubic-control-0.9.0/pkg/kubicctl/fetchKubeconfig.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/fetchKubeconfig.go 2020-01-05 17:46:17.375568044 +0100 @@ -51,7 +51,7 @@ c := pb.NewKubeadmClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() r, err := c.FetchKubeconfig(ctx, &pb.Empty{}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/getStatus.go new/kubic-control-0.9.1/pkg/kubicctl/getStatus.go --- old/kubic-control-0.9.0/pkg/kubicctl/getStatus.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/getStatus.go 2020-01-05 17:46:17.375568044 +0100 @@ -47,9 +47,6 @@ client := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/initMaster.go new/kubic-control-0.9.1/pkg/kubicctl/initMaster.go --- old/kubic-control-0.9.0/pkg/kubicctl/initMaster.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/initMaster.go 2020-01-05 17:46:17.375568044 +0100 @@ -17,7 +17,6 @@ import ( "context" "time" - "flag" "fmt" "os" "io" @@ -64,10 +63,7 @@ client := pb.NewKubeadmClient(conn) - var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - // ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute) defer cancel() fmt.Print ("Initializing kubernetes master can take several minutes, please be patient.\n") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/listNodes.go new/kubic-control-0.9.1/pkg/kubicctl/listNodes.go --- old/kubic-control-0.9.0/pkg/kubicctl/listNodes.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/listNodes.go 2020-01-05 17:46:17.375568044 +0100 @@ -45,10 +45,7 @@ c := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() r, err := c.ListNodes(ctx, &pb.Empty{}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/rebootNode.go new/kubic-control-0.9.1/pkg/kubicctl/rebootNode.go --- old/kubic-control-0.9.0/pkg/kubicctl/rebootNode.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/rebootNode.go 2020-01-05 17:46:17.375568044 +0100 @@ -48,10 +48,7 @@ c := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() r, err := c.RebootNode(ctx, &pb.RebootNodeRequest{NodeNames: nodes}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/removeNode.go new/kubic-control-0.9.1/pkg/kubicctl/removeNode.go --- old/kubic-control-0.9.0/pkg/kubicctl/removeNode.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/removeNode.go 2020-01-05 17:46:17.375568044 +0100 @@ -49,10 +49,7 @@ client := pb.NewKubeadmClient(conn) - // var deadlineMin = flag.Int("deadline_min", 10, "Default deadline in minutes.") - // clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - // ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) defer cancel() stream, err := client.RemoveNode(ctx, &pb.RemoveNodeRequest{NodeNames: nodes}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/root.go new/kubic-control-0.9.1/pkg/kubicctl/root.go --- old/kubic-control-0.9.0/pkg/kubicctl/root.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/root.go 2020-01-05 17:46:17.375568044 +0100 @@ -23,6 +23,7 @@ log "github.com/sirupsen/logrus" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "gopkg.in/ini.v1" "github.com/spf13/cobra" homedir "github.com/mitchellh/go-homedir" "github.com/thkukuk/kubic-control/pkg/rbac" @@ -39,6 +40,8 @@ servername = "localhost" port = "7148" + usercfg = "~/.config/kubicctl/kubicctl.conf" + // Client Certificates crtFile = "~/.config/kubicctl/user.crt" keyFile = "~/.config/kubicctl/user.key" @@ -55,6 +58,20 @@ func Execute() error { + homecfg, err := homedir.Expand(usercfg) + if err == nil { + cfg, cfg_err := ini.LooseLoad(homecfg); + if cfg_err, ok := cfg_err.(*os.PathError); ok { + log.Fatal(cfg_err) + } + if cfg.Section("global").HasKey("server") { + servername = cfg.Section("global").Key("server").String() + } + if cfg.Section("global").HasKey("port") { + port = cfg.Section("global").Key("port").String() + } + } + // if called as root, use admin certificates as default if local // ones don't exit if os.Getuid() == 0 { @@ -89,9 +106,9 @@ DestroyClusterCmd(), rbac.RBACCmd(), GetStatusCmd(), + DeployCmd(), ) - var err error crtFile, err = homedir.Expand(crtFile) if err != nil { log.Fatal(err) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/kubicctl/upgradeKubernetes.go new/kubic-control-0.9.1/pkg/kubicctl/upgradeKubernetes.go --- old/kubic-control-0.9.0/pkg/kubicctl/upgradeKubernetes.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/kubicctl/upgradeKubernetes.go 2020-01-05 17:46:17.375568044 +0100 @@ -17,7 +17,6 @@ import ( "context" "time" - "flag" "fmt" "os" "io" @@ -50,10 +49,7 @@ client := pb.NewKubeadmClient(conn) - var deadlineMin = flag.Int("deadline_min", 20, "Default deadline in minutes.") - clientDeadline := time.Now().Add(time.Duration(*deadlineMin) * time.Minute) - ctx, cancel := context.WithDeadline(context.Background(), clientDeadline) - // ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute) defer cancel() fmt.Print ("Upgrading kubernetes can take a very long time, please be patient.\n") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kubic-control-0.9.0/pkg/tools/sha256sum.go new/kubic-control-0.9.1/pkg/tools/sha256sum.go --- old/kubic-control-0.9.0/pkg/tools/sha256sum.go 2019-10-05 09:58:02.987729172 +0200 +++ new/kubic-control-0.9.1/pkg/tools/sha256sum.go 2020-01-05 17:46:17.379568062 +0100 @@ -21,7 +21,14 @@ "crypto/sha256" ) -func Sha256sum(filePath string) (result string, err error) { +func Sha256sum_b(buffer string) (result string, err error) { + hash := sha256.New() + hash.Write([]byte(buffer)) + result = hex.EncodeToString(hash.Sum(nil)) + return result, nil +} + +func Sha256sum_f(filePath string) (result string, err error) { file, err := os.Open(filePath) if err != nil { return "", err
