-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florian Fordermaier
committed
May 2, 2020
1 parent
9b53f7d
commit 158c631
Showing
3 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import TempYaml from "../../TempYaml" | ||
|
||
class Certificate { | ||
/** | ||
* Creates a ClusterIssuer resource using letsencrypt staging servers and returns the yaml as string. | ||
* | ||
* @param name Name of the cluster issuer resource | ||
*/ | ||
public createCertificate(certName: string, namespace: string, dnsName: string, clusterIssuer: string) : TempYaml { | ||
|
||
var certificateTemplate = | ||
`apiVersion: cert-manager.io/v1alpha2 | ||
kind: Certificate | ||
metadata: | ||
name: ${certName} | ||
namespace: ${namespace} | ||
spec: | ||
secretName: ${certName} | ||
commonName: ${dnsName} | ||
dnsNames: | ||
- ${dnsName} | ||
issuerRef: | ||
name: ${clusterIssuer} | ||
kind: ClusterIssuer`; | ||
|
||
return new TempYaml(certificateTemplate); | ||
} | ||
} | ||
|
||
export default Certificate; |
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,66 @@ | ||
import TempYaml from "../../TempYaml" | ||
|
||
class ClusterIssuer { | ||
|
||
/** | ||
* Creates a ClusterIssuer resource using letsencrypt staging servers and returns the yaml as string. | ||
* | ||
* @param name Name of the cluster issuer resource | ||
*/ | ||
public createForStaging(name: String) : TempYaml { | ||
return this.createYaml(name, true); | ||
} | ||
|
||
/** | ||
* Creates a ClusterIssuer resource using letsencrypt production servers and returns the yaml as string. | ||
* | ||
* @param name Name of the cluster issuer resource | ||
*/ | ||
public createForProd(name: String) : TempYaml { | ||
return this.createYaml(name, false); | ||
} | ||
|
||
private createYaml(name: String, forStaging: Boolean) : TempYaml { | ||
const acmeServer = | ||
forStaging | ||
? "https://acme-staging-v02.api.letsencrypt.org/directory" | ||
: "https://acme-v02.api.letsencrypt.org/directory"; | ||
|
||
const clusterIssuerTemplate = | ||
`apiVersion: cert-manager.io/v1alpha2 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: ${name} | ||
namespace: default | ||
spec: | ||
acme: | ||
server: ${acmeServer} | ||
email: [email protected] | ||
privateKeySecretRef: | ||
name: ${name} | ||
# this is the 'new' way of defining solvers | ||
solvers: | ||
# empty selector will match all Certificate resources that reference this issuer. | ||
# for selecting a specific solver from a Certificate resource (not required right now), see | ||
# https://docs.cert-manager.io/en/latest/tasks/upgrading/upgrading-0.7-0.8.html#performing-an-incremental-switch-to-the-new-format | ||
- selector: {} | ||
dns01: | ||
digitalocean: | ||
tokenSecretRef: | ||
name: dns01-solver-secret | ||
key: token | ||
- selector: | ||
matchLabels: | ||
use-http01-solver: "true" | ||
http01: | ||
ingress: | ||
class: nginx`; | ||
|
||
return new TempYaml(clusterIssuerTemplate); | ||
} | ||
} | ||
|
||
export default ClusterIssuer; | ||
export { ClusterIssuer }; | ||
|