Skip to content

Commit

Permalink
Update cert-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Fordermaier committed May 2, 2020
1 parent 9b53f7d commit 158c631
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pulumix",
"version": "1.0.0",
"version": "1.1.1",
"description": "Some simple extensions and helpers for use with pulumi.",
"main": "index.js",
"scripts": {
Expand Down
30 changes: 30 additions & 0 deletions src/cert-manager/v0.14.0/certificate.ts
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;
66 changes: 66 additions & 0 deletions src/cert-manager/v0.14.0/clusterissuer.ts
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 };

0 comments on commit 158c631

Please sign in to comment.