-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ use new scaffolding and more kustomize features
- Loading branch information
Mengqi Yu
committed
May 6, 2019
1 parent
9672e57
commit a3e6e25
Showing
43 changed files
with
1,388 additions
and
122 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
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 was deleted.
Oops, something went wrong.
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,63 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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. | ||
*/ | ||
|
||
package certmanager | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
// CertManager scaffolds an issuer CR and a certificate CR | ||
type CertManager struct { | ||
input.Input | ||
} | ||
|
||
// GetInput implements input.File | ||
func (p *CertManager) GetInput() (input.Input, error) { | ||
if p.Path == "" { | ||
p.Path = filepath.Join("config", "certmanager", "certificate.yaml") | ||
} | ||
p.TemplateBody = certManagerTemplate | ||
return p.Input, nil | ||
} | ||
|
||
var certManagerTemplate = `# The following manifests contain a self-signed issuer CR and a certificate CR. | ||
# More document can be found at https://docs.cert-manager.io | ||
apiVersion: certmanager.k8s.io/v1alpha1 | ||
kind: Issuer | ||
metadata: | ||
name: selfsigned-issuer | ||
namespace: system | ||
spec: | ||
selfSigned: {} | ||
--- | ||
apiVersion: certmanager.k8s.io/v1alpha1 | ||
kind: Certificate | ||
metadata: | ||
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml | ||
namespace: system | ||
spec: | ||
# $(SERVICENAME) and $(NAMESPACE) will be substituted by kustomize | ||
commonName: $(SERVICENAME).$(NAMESPACE).svc | ||
dnsNames: | ||
- $(SERVICENAME).$(NAMESPACE).svc.cluster.local | ||
issuerRef: | ||
kind: Issuer | ||
name: selfsigned-issuer | ||
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize | ||
` |
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,52 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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. | ||
*/ | ||
|
||
package certmanager | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
// Kustomization scaffolds the kustomizaiton in the certmanager folder | ||
type Kustomization struct { | ||
input.Input | ||
} | ||
|
||
// GetInput implements input.File | ||
func (p *Kustomization) GetInput() (input.Input, error) { | ||
if p.Path == "" { | ||
p.Path = filepath.Join("config", "certmanager", "kustomization.yaml") | ||
} | ||
p.TemplateBody = kustomizationTemplate | ||
return p.Input, nil | ||
} | ||
|
||
var kustomizationTemplate = `resources: | ||
- certificate.yaml | ||
vars: | ||
- name: CERTIFICATENAME | ||
objref: | ||
kind: Certificate | ||
group: certmanager.k8s.io | ||
version: v1alpha1 | ||
name: serving-cert # this name should match the one in certificate.yaml | ||
configurations: | ||
- kustomizeconfig.yaml | ||
` |
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,55 @@ | ||
/* | ||
Copyright 2019 The Kubernetes 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. | ||
*/ | ||
|
||
package certmanager | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
// KustomizeConfig scaffolds the kustomizeconfig in the certmanager folder | ||
type KustomizeConfig struct { | ||
input.Input | ||
} | ||
|
||
// GetInput implements input.File | ||
func (p *KustomizeConfig) GetInput() (input.Input, error) { | ||
if p.Path == "" { | ||
p.Path = filepath.Join("config", "certmanager", "kustomizeconfig.yaml") | ||
} | ||
p.TemplateBody = kustomizeConfigTemplate | ||
return p.Input, nil | ||
} | ||
|
||
var kustomizeConfigTemplate = `# This configuration is for teaching kustomize how to update name ref and var substitution | ||
nameReference: | ||
- kind: Issuer | ||
group: certmanager.k8s.io | ||
fieldSpecs: | ||
- kind: Certificate | ||
group: certmanager.k8s.io | ||
path: spec/issuerRef/name | ||
varReference: | ||
- kind: Certificate | ||
group: certmanager.k8s.io | ||
path: spec/commonName | ||
- kind: Certificate | ||
group: certmanager.k8s.io | ||
path: spec/dnsNames | ||
` |
Oops, something went wrong.