Skip to content

Commit 21bda3c

Browse files
feat: embed the code into the image
1 parent 76e03ae commit 21bda3c

9 files changed

+19
-18
lines changed

0_install.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env bash
22
set -eo pipefail
33

4-
mkdir -p ./kube
4+
mkdir -p /state/kube
55

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
88
fi
99

1010
# connect current container to the kind network
@@ -14,7 +14,7 @@ if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${container
1414
fi
1515

1616
# 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
1818
kind export kubeconfig --internal -n 5min-idp --kubeconfig "$kubeconfig_docker"
1919

2020
humctl_token=$(yq .token /root/.humctl)

1_demo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ workload_host=$(humctl get active-resources --app 5min-idp --env development -o
4949
echo "Waiting for workload to be available"
5050

5151
# 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"
5353

5454
echo "Workload available at: http://$workload_host:30080"

2_cleanup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${container
88
fi
99

1010
humctl_token=$(yq .token /root/.humctl)
11-
kubeconfig_docker=$(pwd)/kube/config-internal.yaml
11+
kubeconfig_docker=/state/kube/config-internal.yaml
1212

1313
export HUMANITEC_TOKEN=$humctl_token
1414
export TF_VAR_humanitec_org=$HUMANITEC_ORG

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ RUN mkdir /tmp/humctl && \
4949
humctl completion bash > /etc/bash_completion.d/humctl && \
5050
rm -rf /tmp/humctl
5151

52+
ENV KUBECONFIG="/state/kube/config-internal.yaml"
53+
54+
COPY . /app
55+
5256
WORKDIR /app
5357

5458
ENTRYPOINT ["/bin/bash"]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ lint: lint-init
2929
test: build check-image
3030
docker run --rm -i -h 5min-idp --name 5min-idp \
3131
-e HUMANITEC_ORG \
32-
-v $(PWD):/app \
32+
-v hum-5min-idp:/state \
3333
-v $(HOME)/.humctl:/root/.humctl \
3434
-v /var/run/docker.sock:/var/run/docker.sock \
3535
--network bridge \

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export HUMANITEC_ORG=MY_ORG
2323
```bash
2424
docker run --rm -it -h 5min-idp --name 5min-idp --pull always \
2525
-e HUMANITEC_ORG \
26-
-v $(PWD):/app \
26+
-v hum-5min-idp:/state \
2727
-v $HOME/.humctl:/root/.humctl \
2828
-v /var/run/docker.sock:/var/run/docker.sock \
2929
--network bridge \

setup/terraform/idp-cluster.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ resource "humanitec_resource_definition_criteria" "agent" {
5555
}
5656

5757
locals {
58-
kubeconfig = yamldecode(file(var.agent_kubeconfig))
58+
kubeconfig = yamldecode(file(var.kubeconfig))
5959
}
6060

6161
resource "humanitec_resource_definition" "local_cluster" {

setup/terraform/providers.tf

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
terraform {
2+
backend "local" {
3+
path = "/state/terraform/terraform.tfstate"
4+
}
5+
26
required_providers {
37
helm = {
48
source = "hashicorp/helm"
@@ -25,7 +29,6 @@ provider "humanitec" {
2529
org_id = var.humanitec_org
2630
}
2731

28-
2932
provider "helm" {
3033
kubernetes {
3134
config_path = var.kubeconfig

setup/terraform/variables.tf

+2-8
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ variable "agent_id" {
1111
}
1212

1313
variable "kubeconfig" {
14-
description = "Kubeconfig used by terraform"
14+
description = "Kubeconfig used by the Humanitec Agent / terraform"
1515
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"
2317
}
2418

2519
resource "tls_private_key" "agent_private_key" {

0 commit comments

Comments
 (0)