I want to access the kubernets service with the url http://staging.steinko.com/helloworld. I have spesified the providing of the cluster pod, service and in Pulumi The cluster looks like this
import * as k8s from "@pulumi/kubernetes"
import * as pulumi from "@pulumi/pulumi"
import * as gcp from "@pulumi/gcp"
import * as config from "./config"
const name = "gradle-ci-cd-cluster";
// Create a GKE cluster
export const cluster = new gcp.container.Cluster(name, { name: name,
project: config.cloudProject,
clusterAutoscaling: {enabled: true, resourceLimits:[ {resourceType: 'cpu', minimum:1 ,maximum:20 },
{resourceType: 'memory', minimum:1 ,maximum:64 }
]
},
initialNodeCount: 1,
nodeConfig: {
machineType: "e2-standard-2",
oauthScopes: [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append",
"https://www.googleapis.com/auth/ndev.clouddns.readwrite"
],
},
location: config.cloudLocation,
});
// Manufacture a GKE-style kubeconfig. Note that this is slightly "different"
// because of the way GKE requires gcloud to be in the picture for cluster
// authentication (rather than using the client cert/key directly).
export const kubeconfig = pulumi.
all([ cluster.name, cluster.endpoint, cluster.masterAuth ]).
apply(([ name, endpoint, masterAuth ]) => {
const context = `${config.cloudProject}_${config.cloudLocation}_${name}`;
return `apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${masterAuth.clusterCaCertificate}
server: https://${endpoint}
name: ${context}
contexts:
- context:
cluster: ${context}
user: ${context}
name: ${context}
current-context: ${context}
kind: Config
preferences: {}
users:
- name: ${context}
user:
auth-provider:
config:
cmd-args: config config-helper --format=json
cmd-path: gcloud
expiry-key: '{.credential.token_expiry}'
token-key: '{.credential.access_token}'
name: gcp
`;
});
// Create a Kubernetes provider instance that uses our cluster from above.
export const clusterProvider = new k8s.Provider(name, {
kubeconfig: kubeconfig,
});
The Name Space, Deployment, Service Manage Zone and RecordSet looks like this
import * as k8s from "@pulumi/kubernetes";
import {clusterProvider} from "./Cluster"
import * as gcp from "@pulumi/gcp";
import * as pulumi from "@pulumi/pulumi";
const name = "hello-world"
export const nameSpace = new k8s.core.v1.Namespace('staging',{metadata: {name:'staging'}},{provider: clusterProvider})
export const nameSpaceName = nameSpace.metadata.name;
const appLabels = { appClass: name }
export const deployment = new k8s.apps.v1.Deployment(name, {
metadata: { labels: appLabels,
namespace: nameSpaceName
},
spec: {
replicas: 1,
selector: { matchLabels: appLabels },
template: {
metadata: {
labels: appLabels,
},
spec: {
containers: [{ name: name,
image: "docker.io/steinko/gradle-ci-cd",
ports: [{ name: "http", containerPort: 8080 }],
livenessProbe:{ httpGet:{path:'/actuator/health/liveness',
port: 8080},
initialDelaySeconds:5,
timeoutSeconds: 1,
periodSeconds: 10,
failureThreshold: 3
} ,
readinessProbe:{ httpGet:{path:'/actuator/health/readiness',
port: 8080},
initialDelaySeconds:5,
timeoutSeconds: 1,
periodSeconds: 10,
failureThreshold: 3
}
}],
}
}
}
},{provider: clusterProvider});
export const deploymentName = deployment.metadata.name;
export const service = new k8s.core.v1.Service(name,
{
metadata: {
labels: appLabels,
namespace: nameSpaceName ,
name:name,
annotations: { 'external-dns.alpha.kubernetes.io/hostname':'service.staging.steinko.org'}
},
spec: {
type: 'LoadBalancer',
ports: [{port: 8080, targetPort: 8080, protocol:'TCP' } ],
selector: appLabels,
} ,
},
{provider: clusterProvider}
)
export const serviceName = service.metadata.name;
export const servicePublicIP = service.status.loadBalancer.ingress[0].ip
const zone = new gcp.dns.ManagedZone("steinko-org", {dnsName: "steinko.org.", project: 'springboot22', name:'staging-zone'});
const serviceRecordSet = new gcp.dns.RecordSet("serviceRecordSet", {
name: "staging.steinko.org.",
type: "A",
ttl: 300,
project: 'springboot22',
managedZone: zone.name,
rrdatas: [servicePublicIP],
});
When running pulumi up gives following report
steinko@Steins-MacBook-Pro infAsCode % pulumi up
Previewing update (dev)
View Live: https://app.pulumi.com/steinko/Gradle-Ci-CD/dev/previews/c8ae9e31-a1c1-4d77-9f47-bb00ba136c51
Type Name Plan
+ pulumi:pulumi:Stack Gradle-Ci-CD-dev create
+ ├─ gcp:dns:ManagedZone steinko-org create
+ ├─ gcp:container:Cluster gradle-ci-cd-cluster create
+ ├─ pulumi:providers:kubernetes gradle-ci-cd-cluster create
+ ├─ kubernetes:core/v1:Namespace staging create
+ ├─ kubernetes:core/v1:Service hello-world create
+ ├─ kubernetes:apps/v1:Deployment hello-world create
+ └─ gcp:dns:RecordSet serviceRecordSet create
Resources:
+ 8 to create
Do you want to perform this update? yes
Updating (dev)
View Live: https://app.pulumi.com/steinko/Gradle-Ci-CD/dev/updates/37
Type Name Status
+ pulumi:pulumi:Stack Gradle-Ci-CD-dev created
+ ├─ gcp:dns:ManagedZone steinko-org created
+ ├─ gcp:container:Cluster gradle-ci-cd-cluster created
+ ├─ pulumi:providers:kubernetes gradle-ci-cd-cluster created
+ ├─ kubernetes:core/v1:Namespace staging created
+ ├─ kubernetes:core/v1:Service hello-world created
+ ├─ kubernetes:apps/v1:Deployment hello-world created
+ └─ gcp:dns:RecordSet serviceRecordSet created
Outputs:
deployment : {
apiVersion: "apps/v1"
id : "staging/hello-world-6l7hw292"
kind : "Deployment"
metadata : {
annotations : {
deployment.kubernetes.io/revision : "1"
kubectl.kubernetes.io/last-applied-configuration: "{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{\"pulumi.com/autonamed\":\"true\"},\"labels\":{\"app.kubernetes.io/managed-by\":\"pulumi\",\"appClass\":\"hello-world\"},\"name\":\"hello-world-6l7hw292\",\"namespace\":\"staging\"},\"spec\":{\"replicas\":1,\"selector\":{\"matchLabels\":{\"appClass\":\"hello-world\"}},\"template\":{\"metadata\":{\"labels\":{\"appClass\":\"hello-world\"}},\"spec\":{\"containers\":[{\"image\":\"docker.io/steinko/gradle-ci-cd\",\"livenessProbe\":{\"failureThreshold\":3,\"httpGet\":{\"path\":\"/actuator/health/liveness\",\"port\":8080},\"initialDelaySeconds\":5,\"periodSeconds\":10,\"timeoutSeconds\":1},\"name\":\"hello-world\",\"ports\":[{\"containerPort\":8080,\"name\":\"http\"}],\"readinessProbe\":{\"failureThreshold\":3,\"httpGet\":{\"path\":\"/actuator/health/readiness\",\"port\":8080},\"initialDelaySeconds\":5,\"periodSeconds\":10,\"timeoutSeconds\":1}}]}}}}\n"
pulumi.com/autonamed : "true"
}
creationTimestamp: "2021-05-19T07:38:52Z"
generation : 1
labels : {
app.kubernetes.io/managed-by: "pulumi"
appClass : "hello-world"
}
managedFields : [
[0]: {
apiVersion: "apps/v1"
fieldsType: "FieldsV1"
fieldsV1 : {
f:metadata: {
f:annotations: {
}
f:labels : {
}
}
f:spec : {
f:selector : {
f:matchLabels: {
}
}
f:strategy : {
f:rollingUpdate: {
}
}
f:template : {
f:metadata: {
f:labels: {
}
}
f:spec : {
f:containers : {
k:{"name":"hello-world"}: {
f:livenessProbe : {
f:httpGet : {
}
}
f:ports : {
k:{"containerPort":8080,"protocol":"TCP"}: {
}
}
f:readinessProbe : {
f:httpGet : {
}
}
}
}
}
}
}
}
manager : "pulumi-resource-kubernetes"
operation : "Update"
time : "2021-05-19T07:38:52Z"
}
[1]: {
apiVersion: "apps/v1"
fieldsType: "FieldsV1"
fieldsV1 : {
f:metadata: {
f:annotations: {
}
}
f:status : {
f:conditions : {
k:{"type":"Available"} : {
}
k:{"type":"Progressing"}: {
}
}
}
}
manager : "kube-controller-manager"
operation : "Update"
time : "2021-05-19T07:39:53Z"
}
]
name : "hello-world-6l7hw292"
namespace : "staging"
resourceVersion : "1349"
selfLink : "/apis/apps/v1/namespaces/staging/deployments/hello-world-6l7hw292"
uid : "300e8e9b-8385-4d90-9913-8eb12fe18183"
}
spec : {
progressDeadlineSeconds: 600
replicas : 1
revisionHistoryLimit : 10
selector : {
matchLabels: {
appClass: "hello-world"
}
}
strategy : {
rollingUpdate: {
maxSurge : "25%"
maxUnavailable: "25%"
}
type : "RollingUpdate"
}
template : {
metadata: {
labels: {
appClass: "hello-world"
}
}
spec : {
containers : [
[0]: {
image : "docker.io/steinko/gradle-ci-cd"
imagePullPolicy : "Always"
livenessProbe : {
failureThreshold : 3
httpGet : {
path : "/actuator/health/liveness"
port : 8080
scheme: "HTTP"
}
initialDelaySeconds: 5
periodSeconds : 10
successThreshold : 1
timeoutSeconds : 1
}
name : "hello-world"
ports : [
[0]: {
containerPort: 8080
name : "http"
protocol : "TCP"
}
]
readinessProbe : {
failureThreshold : 3
httpGet : {
path : "/actuator/health/readiness"
port : 8080
scheme: "HTTP"
}
initialDelaySeconds: 5
periodSeconds : 10
successThreshold : 1
timeoutSeconds : 1
}
terminationMessagePath : "/dev/termination-log"
terminationMessagePolicy: "File"
}
]
dnsPolicy : "ClusterFirst"
restartPolicy : "Always"
schedulerName : "default-scheduler"
terminationGracePeriodSeconds: 30
}
}
}
status : {
availableReplicas : 1
conditions : [
[0]: {
lastTransitionTime: "2021-05-19T07:39:53Z"
lastUpdateTime : "2021-05-19T07:39:53Z"
message : "Deployment has minimum availability."
reason : "MinimumReplicasAvailable"
status : "True"
type : "Available"
}
[1]: {
lastTransitionTime: "2021-05-19T07:38:52Z"
lastUpdateTime : "2021-05-19T07:39:53Z"
message : "ReplicaSet \"hello-world-6l7hw292-68f4b89dcf\" has successfully progressed."
reason : "NewReplicaSetAvailable"
status : "True"
type : "Progressing"
}
]
observedGeneration: 1
readyReplicas : 1
replicas : 1
updatedReplicas : 1
}
urn : "urn:pulumi:dev::Gradle-Ci-CD::kubernetes:apps/v1:Deployment::hello-world"
}
deploymentName : "hello-world-6l7hw292"
nameSpace : {
apiVersion: "v1"
id : "staging"
kind : "Namespace"
metadata : {
annotations : {
kubectl.kubernetes.io/last-applied-configuration: "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"labels\":{\"app.kubernetes.io/managed-by\":\"pulumi\"},\"name\":\"staging\"}}\n"
}
creationTimestamp: "2021-05-19T07:38:52Z"
labels : {
app.kubernetes.io/managed-by: "pulumi"
}
managedFields : [
[0]: {
apiVersion: "v1"
fieldsType: "FieldsV1"
fieldsV1 : {
f:metadata: {
f:annotations: {
}
f:labels : {
}
}
f:status : {
}
}
manager : "pulumi-resource-kubernetes"
operation : "Update"
time : "2021-05-19T07:38:52Z"
}
]
name : "staging"
resourceVersion : "779"
selfLink : "/api/v1/namespaces/staging"
uid : "a722d333-2a86-4e96-9ce1-6ded3a84a64c"
}
spec : {
finalizers: [
[0]: "kubernetes"
]
}
status : {
phase: "Active"
}
urn : "urn:pulumi:dev::Gradle-Ci-CD::kubernetes:core/v1:Namespace::staging"
}
nameSpaceName : "staging"
service : {
apiVersion: "v1"
id : "staging/hello-world"
kind : "Service"
metadata : {
annotations : {
external-dns.alpha.kubernetes.io/hostname : "service.staging.steinko.org"
kubectl.kubernetes.io/last-applied-configuration: "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{\"external-dns.alpha.kubernetes.io/hostname\":\"service.staging.steinko.org\"},\"labels\":{\"app.kubernetes.io/managed-by\":\"pulumi\",\"appClass\":\"hello-world\"},\"name\":\"hello-world\",\"namespace\":\"staging\"},\"spec\":{\"ports\":[{\"port\":8080,\"protocol\":\"TCP\",\"targetPort\":8080}],\"selector\":{\"appClass\":\"hello-world\"},\"type\":\"LoadBalancer\"}}\n"
}
creationTimestamp: "2021-05-19T07:38:52Z"
finalizers : [
[0]: "service.kubernetes.io/load-balancer-cleanup"
]
labels : {
app.kubernetes.io/managed-by: "pulumi"
appClass : "hello-world"
}
managedFields : [
[0]: {
apiVersion: "v1"
fieldsType: "FieldsV1"
fieldsV1 : {
f:metadata: {
f:annotations: {
}
f:labels : {
}
}
f:spec : {
f:ports : {
k:{"port":8080,"protocol":"TCP"}: {
}
}
f:selector : {
}
}
}
manager : "pulumi-resource-kubernetes"
operation : "Update"
time : "2021-05-19T07:38:52Z"
}
[1]: {
apiVersion: "v1"
fieldsType: "FieldsV1"
fieldsV1 : {
f:metadata: {
f:finalizers: {
}
}
f:status : {
f:loadBalancer: {
}
}
}
manager : "kube-controller-manager"
operation : "Update"
time : "2021-05-19T07:39:39Z"
}
]
name : "hello-world"
namespace : "staging"
resourceVersion : "1167"
selfLink : "/api/v1/namespaces/staging/services/hello-world"
uid : "124042c4-b8db-4962-ad00-996dc34e1903"
}
spec : {
clusterIP : "10.43.248.226"
externalTrafficPolicy: "Cluster"
ports : [
[0]: {
nodePort : 31864
port : 8080
protocol : "TCP"
targetPort: 8080
}
]
selector : {
appClass: "hello-world"
}
sessionAffinity : "None"
type : "LoadBalancer"
}
status : {
loadBalancer: {
ingress: [
[0]: {
ip: "35.228.10.250"
}
]
}
}
urn : "urn:pulumi:dev::Gradle-Ci-CD::kubernetes:core/v1:Service::hello-world"
}
serviceName : "hello-world"
servicePublicIP: "35.228.10.250"
Resources:
+ 8 created
Duration: 3m37s
When I try to browse http://35.228.10.250/helloworld i get the message This site can’t be reached35.228.10.250 took too long to respond. Try:
Checking the connection Checking the proxy and the firewall ERR_CONNECTION_TIMED_OUT
When I try the http://staging.steinko.com/helloworld I get the message This site can’t be reachedCheck if there is a typo in staging.steinko.com. DNS_PROBE_FINISHED_NXDOMAIN
What must I do to get access to the service in a global url?