-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade controller-runtime to v0.3.0 (#712)
* Upgrade controller-runtime to v0.3.0 * Upstream k8s libs are updated to kubernetes-1.15.4 release tag * Fixed many API breaking changes * Logic regarding checking version of CCM is removed Signed-off-by: Artiom Diomin <[email protected]> * Whitelist ICS license for dependencies Signed-off-by: Artiom Diomin <[email protected]> * Fix borken API in e2e tests Signed-off-by: Artiom Diomin <[email protected]> * Fix linter Signed-off-by: Artiom Diomin <[email protected]> * Removed HackIssue321InitDynamicClient hack * upstream issue kubernetes-sigs/controller-runtime#321 Signed-off-by: Artiom Diomin <[email protected]> * Return back accidentally removed initialization of dynamic client Signed-off-by: Artiom Diomin <[email protected]> * Revert "Removed HackIssue321InitDynamicClient hack" This reverts commit 73710af. Signed-off-by: Artiom Diomin <[email protected]> * Better comment reason for pki.go existance. Signed-off-by: Artiom Diomin <[email protected]>
- Loading branch information
1 parent
0ed7b26
commit 2ee20c7
Showing
23 changed files
with
399 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
blacklist: | ||
- GPL-2.0 | ||
- GPL-2.0 | ||
|
||
whitelist: | ||
- Apache-2.0 | ||
- MIT | ||
- NewBSD | ||
- FreeBSD | ||
- LGPL-3.0 | ||
- MPL-2.0 | ||
- Apache-2.0 | ||
- FreeBSD | ||
- ISC | ||
- LGPL-3.0 | ||
- MIT | ||
- MPL-2.0 | ||
- NewBSD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
Copyright 2019 The KubeOne Authors. | ||
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. | ||
*/ | ||
|
||
// Upstream PR https://github.com/kubernetes/kubernetes/pull/73198 moved few | ||
// functions from "k8s.io/client-go/util/cert" to | ||
// "k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil". | ||
// | ||
// to avoid importing "k8s.io/kubernetes" those functions are copied over here. | ||
|
||
package certificate | ||
|
||
import ( | ||
"crypto" | ||
"crypto/rand" | ||
"crypto/rsa" | ||
"crypto/x509" | ||
"crypto/x509/pkix" | ||
"encoding/pem" | ||
"math" | ||
"math/big" | ||
"time" | ||
|
||
"github.com/pkg/errors" | ||
|
||
certutil "k8s.io/client-go/util/cert" | ||
) | ||
|
||
const ( | ||
// PrivateKeyBlockType is a possible value for pem.Block.Type. | ||
PrivateKeyBlockType = "PRIVATE KEY" | ||
// PublicKeyBlockType is a possible value for pem.Block.Type. | ||
PublicKeyBlockType = "PUBLIC KEY" | ||
// CertificateBlockType is a possible value for pem.Block.Type. | ||
CertificateBlockType = "CERTIFICATE" | ||
// RSAPrivateKeyBlockType is a possible value for pem.Block.Type. | ||
RSAPrivateKeyBlockType = "RSA PRIVATE KEY" | ||
rsaKeySize = 2048 | ||
duration365d = time.Hour * 24 * 365 | ||
) | ||
|
||
// EncodeCertPEM returns PEM-endcoded certificate data | ||
func EncodeCertPEM(cert *x509.Certificate) []byte { | ||
block := pem.Block{ | ||
Type: CertificateBlockType, | ||
Bytes: cert.Raw, | ||
} | ||
return pem.EncodeToMemory(&block) | ||
} | ||
|
||
// EncodePublicKeyPEM returns PEM-encoded public data | ||
func EncodePublicKeyPEM(key *rsa.PublicKey) ([]byte, error) { | ||
der, err := x509.MarshalPKIXPublicKey(key) | ||
if err != nil { | ||
return []byte{}, err | ||
} | ||
block := pem.Block{ | ||
Type: PublicKeyBlockType, | ||
Bytes: der, | ||
} | ||
return pem.EncodeToMemory(&block), nil | ||
} | ||
|
||
// EncodePrivateKeyPEM returns PEM-encoded private key data | ||
func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte { | ||
block := pem.Block{ | ||
Type: RSAPrivateKeyBlockType, | ||
Bytes: x509.MarshalPKCS1PrivateKey(key), | ||
} | ||
return pem.EncodeToMemory(&block) | ||
} | ||
|
||
// NewPrivateKey creates an RSA private key | ||
func NewPrivateKey() (*rsa.PrivateKey, error) { | ||
return rsa.GenerateKey(rand.Reader, rsaKeySize) | ||
} | ||
|
||
// NewSignedCert creates a signed certificate using the given CA certificate and key | ||
func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error) { | ||
serial, err := rand.Int(rand.Reader, new(big.Int).SetInt64(math.MaxInt64)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(cfg.CommonName) == 0 { | ||
return nil, errors.New("must specify a CommonName") | ||
} | ||
if len(cfg.Usages) == 0 { | ||
return nil, errors.New("must specify at least one ExtKeyUsage") | ||
} | ||
|
||
certTmpl := x509.Certificate{ | ||
Subject: pkix.Name{ | ||
CommonName: cfg.CommonName, | ||
Organization: cfg.Organization, | ||
}, | ||
DNSNames: cfg.AltNames.DNSNames, | ||
IPAddresses: cfg.AltNames.IPs, | ||
SerialNumber: serial, | ||
NotBefore: caCert.NotBefore, | ||
NotAfter: time.Now().Add(duration365d).UTC(), | ||
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, | ||
ExtKeyUsage: cfg.Usages, | ||
} | ||
certDERBytes, err := x509.CreateCertificate(rand.Reader, &certTmpl, caCert, key.Public(), caKey) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return x509.ParseCertificate(certDERBytes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.