Updated examples to export IP (Issue and fixed URL error with readiness probe
MODIFY
kubernetes-py-jenkins/__main__.py
kubernetes-py-jenkins/__main__.py
@@ -20,3 +20,4 @@ instance = jenkins.Instance(
"cpu": "100m",
},
)
+pulumi.export("external_ip", instance.external_ip)

MODIFY
kubernetes-py-jenkins/jenkins.py
kubernetes-py-jenkins/jenkins.py
@@ -183,5 +183,6 @@ class Instance (pulumi.ComponentResource):
opts=ResourceOptions(parent=self)
)
- # This component resource has no outputs.
- self.register_outputs({})
+ ingress = service.status["load_balancer"]["ingress"][0]
+ self.external_ip = ingress.apply(lambda x: x.get("ip", x["hostname"]))
+ self.register_outputs({"external_ip": self.external_ip})

MODIFY
kubernetes-ts-jenkins/index.ts
kubernetes-ts-jenkins/index.ts
@@ -21,3 +21,4 @@ const instance = new jenkins.Instance({
cpu: "100m",
},
});
+export const externalIp = instance.externalIp;

MODIFY
kubernetes-ts-jenkins/jenkins.ts
kubernetes-ts-jenkins/jenkins.ts
import * as k8s from "@pulumi/kubernetes";
import * as input from "@pulumi/kubernetes/types/input";
import * as pulumi from "@pulumi/pulumi";
+import { externalIp } from ".";
function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment {
const image = args.image || {
@@ -72,7 +73,7 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment {
],
livenessProbe: {
httpGet: {
- path: "/",
+ path: "/login",
port: "http",
},
initialDelaySeconds: 180,
@@ -81,7 +82,7 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment {
},
readinessProbe: {
httpGet: {
- path: "/",
+ path: "/login",
port: "http",
},
initialDelaySeconds: 90,
@@ -112,6 +113,9 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment {
* ComponentResource for a Jenkins instance running in a Kubernetes cluster.
*/
export class Instance extends pulumi.ComponentResource {
+
+ externalIp: pulumi.Output<string>;
+
constructor(args: JenkinsArgs, opts?: pulumi.ResourceOptions) {
super("jenkins:jenkins:Instance", args.name, args, opts);
@@ -130,9 +134,6 @@ export class Instance extends pulumi.ComponentResource {
const pvc = new k8s.core.v1.PersistentVolumeClaim(`${args.name}-pvc`, {
metadata: {
name: args.name,
- annotations: {
- "volume.beta.kubernetes.io/storage-class": `${args.storageClass || "standard" }`,
- },
},
spec: {
accessModes: ["ReadWriteOnce"],
@@ -172,9 +173,8 @@ export class Instance extends pulumi.ComponentResource {
},
},
}, { parent: this });
-
- // This component resource has no outputs.
- this.registerOutputs({});
+ this.externalIp = service.status.loadBalancer.ingress[0].ip;
+ this.registerOutputs({externalIp: externalIp});
}
}

Updated examples to export IP (Issue #718), and fixed URL error with readiness probe (#733)

Co-authored-by: Vova Ivanov <jetvova@gmail.com>