Commit e5bb4cd 1 parent 76e03ae commit e5bb4cd Copy full SHA for e5bb4cd
File tree 9 files changed +21
-20
lines changed
9 files changed +21
-20
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
set -eo pipefail
3
3
4
- mkdir -p . /kube
4
+ mkdir -p /state /kube
5
5
6
- if [ ! -f . /kube/config.yaml ]; then
7
- kind create cluster -n 5min-idp --kubeconfig . /kube/config.yaml --config ./setup/kind/cluster.yaml
6
+ if [ ! -f /state /kube/config.yaml ]; then
7
+ kind create cluster -n 5min-idp --kubeconfig /state /kube/config.yaml --config ./setup/kind/cluster.yaml
8
8
fi
9
9
10
10
# connect current container to the kind network
@@ -14,7 +14,7 @@ if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${container
14
14
fi
15
15
16
16
# used by humanitec-agent / inside docker to reach the cluster
17
- kubeconfig_docker=$( pwd ) /kube/config-internal.yaml
17
+ kubeconfig_docker=/state /kube/config-internal.yaml
18
18
kind export kubeconfig --internal -n 5min-idp --kubeconfig " $kubeconfig_docker "
19
19
20
20
humctl_token=$( yq .token /root/.humctl)
Original file line number Diff line number Diff line change @@ -49,6 +49,6 @@ workload_host=$(humctl get active-resources --app 5min-idp --env development -o
49
49
echo " Waiting for workload to be available"
50
50
51
51
# manually change the host here as the workload host resolves to localhost, which is not reachable from the container
52
- curl -I --retry 10 --retry-delay 3 --connect-to " $workload_host :30080:5min-idp-control-plane:30080" " http://$workload_host :30080"
52
+ curl -I --retry 10 --retry-delay 3 --retry-all-errors -- connect-to " $workload_host :30080:5min-idp-control-plane:30080" --fail " http://$workload_host :30080"
53
53
54
54
echo " Workload available at: http://$workload_host :30080"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${container
8
8
fi
9
9
10
10
humctl_token=$( yq .token /root/.humctl)
11
- kubeconfig_docker=$( pwd ) /kube/config-internal.yaml
11
+ kubeconfig_docker=/state /kube/config-internal.yaml
12
12
13
13
export HUMANITEC_TOKEN=$humctl_token
14
14
export TF_VAR_humanitec_org=$HUMANITEC_ORG
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ RUN mkdir /tmp/humctl && \
49
49
humctl completion bash > /etc/bash_completion.d/humctl && \
50
50
rm -rf /tmp/humctl
51
51
52
+ ENV KUBECONFIG="/state/kube/config-internal.yaml"
53
+
54
+ COPY . /app
55
+
52
56
WORKDIR /app
53
57
54
58
ENTRYPOINT ["/bin/bash" ]
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ lint: lint-init
29
29
test : build check-image
30
30
docker run --rm -i -h 5min-idp --name 5min-idp \
31
31
-e HUMANITEC_ORG \
32
- -v $( PWD ) :/app \
32
+ -v hum-5min-idp :/state \
33
33
-v $(HOME ) /.humctl :/root/.humctl \
34
34
-v /var/run/docker.sock :/var/run/docker.sock \
35
35
--network bridge \
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export HUMANITEC_ORG=MY_ORG
23
23
``` bash
24
24
docker run --rm -it -h 5min-idp --name 5min-idp --pull always \
25
25
-e HUMANITEC_ORG \
26
- -v $( PWD ) :/app \
26
+ -v hum-5min-idp:/state \
27
27
-v $HOME /.humctl:/root/.humctl \
28
28
-v /var/run/docker.sock:/var/run/docker.sock \
29
29
--network bridge \
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ resource "humanitec_resource_definition_criteria" "agent" {
55
55
}
56
56
57
57
locals {
58
- kubeconfig = yamldecode (file (var. agent_kubeconfig ))
58
+ parsed_kubeconfig = yamldecode (file (var. kubeconfig ))
59
59
}
60
60
61
61
resource "humanitec_resource_definition" "local_cluster" {
@@ -67,11 +67,11 @@ resource "humanitec_resource_definition" "local_cluster" {
67
67
driver_inputs = {
68
68
values_string = jsonencode ({
69
69
loadbalancer = " 0.0.0.0" # ensure dns records are created pointing to localhost
70
- cluster_data = local.kubeconfig [" clusters" ][0 ][" cluster" ]
70
+ cluster_data = local.parsed_kubeconfig [" clusters" ][0 ][" cluster" ]
71
71
})
72
72
secrets_string = jsonencode ({
73
73
agent_url = " $${resources['agent#agent'].outputs.url}"
74
- credentials = local.kubeconfig [" users" ][0 ][" user" ]
74
+ credentials = local.parsed_kubeconfig [" users" ][0 ][" user" ]
75
75
})
76
76
}
77
77
Original file line number Diff line number Diff line change 1
1
terraform {
2
+ backend "local" {
3
+ path = " /state/terraform/terraform.tfstate"
4
+ }
5
+
2
6
required_providers {
3
7
helm = {
4
8
source = " hashicorp/helm"
@@ -25,7 +29,6 @@ provider "humanitec" {
25
29
org_id = var. humanitec_org
26
30
}
27
31
28
-
29
32
provider "helm" {
30
33
kubernetes {
31
34
config_path = var. kubeconfig
Original file line number Diff line number Diff line change @@ -11,15 +11,9 @@ variable "agent_id" {
11
11
}
12
12
13
13
variable "kubeconfig" {
14
- description = " Kubeconfig used by terraform"
14
+ description = " Kubeconfig used by the Humanitec Agent / terraform"
15
15
type = string
16
- default = " ../../kube/config.yaml"
17
- }
18
-
19
- variable "agent_kubeconfig" {
20
- description = " Kubeconfig used by the Humanitec Agent"
21
- type = string
22
- default = " ../../kube/config-internal.yaml"
16
+ default = " /state/kube/config-internal.yaml"
23
17
}
24
18
25
19
resource "tls_private_key" "agent_private_key" {
You can’t perform that action at this time.
0 commit comments