fix: route image resolution to internal cluster dns service registry
This commit is contained in:
parent
abf3d6ce8c
commit
ed46acc154
|
|
@ -27,7 +27,7 @@ spec:
|
|||
topologyKey: "kubernetes.io/hostname"
|
||||
containers:
|
||||
- name: php-app
|
||||
image: 192.168.100.68:30500/my-php-app:v1
|
||||
image: local-registry-svc.container-registry.svc.cluster.local:5000/php-website:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ provider "kubernetes" {
|
|||
}
|
||||
|
||||
resource "kubernetes_manifest" "container_registry" {
|
||||
field_manager {
|
||||
force_conflicts = true
|
||||
}
|
||||
|
||||
manifest = {
|
||||
apiVersion = "argoproj.io/v1alpha1"
|
||||
kind = "Application"
|
||||
|
|
@ -23,7 +27,6 @@ resource "kubernetes_manifest" "container_registry" {
|
|||
spec = {
|
||||
project = "default"
|
||||
source = {
|
||||
# Targets your laptop's private IP and filesystem path via SSH
|
||||
repoURL = "ssh://jv@192.168.100.68/home/jv/git-server/my-homelab-configs.git"
|
||||
targetRevision = "HEAD"
|
||||
path = "apps/container-registry"
|
||||
|
|
@ -45,6 +48,11 @@ resource "kubernetes_manifest" "container_registry" {
|
|||
|
||||
resource "kubernetes_manifest" "production_website" {
|
||||
depends_on = [kubernetes_manifest.container_registry]
|
||||
|
||||
field_manager {
|
||||
force_conflicts = true
|
||||
}
|
||||
|
||||
manifest = {
|
||||
apiVersion = "argoproj.io/v1alpha1"
|
||||
kind = "Application"
|
||||
|
|
@ -55,7 +63,6 @@ resource "kubernetes_manifest" "production_website" {
|
|||
spec = {
|
||||
project = "default"
|
||||
source = {
|
||||
# Targets your laptop's private IP and filesystem path via SSH
|
||||
repoURL = "ssh://jv@192.168.100.68/home/jv/git-server/my-homelab-configs.git"
|
||||
targetRevision = "HEAD"
|
||||
path = "apps/website"
|
||||
|
|
|
|||
33
lab.sh
33
lab.sh
|
|
@ -1,6 +1,20 @@
|
|||
up() {
|
||||
echo "Deploying the homelab infrastructure..."
|
||||
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
|
||||
cat <<EOF > /tmp/buildx-config.toml
|
||||
[registry."127.0.0.1:30500"]
|
||||
http = true
|
||||
[registry."localhost:30500"]
|
||||
http = true
|
||||
EOF
|
||||
|
||||
docker buildx rm lab-builder 2>/dev/null || true
|
||||
|
||||
docker buildx create --name lab-builder --driver docker-container --driver-opt network=host --config /tmp/buildx-config.toml --use
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
cd bootstrap/cluster
|
||||
tofu init
|
||||
tofu apply -auto-approve
|
||||
|
|
@ -14,6 +28,22 @@ up() {
|
|||
tofu apply -auto-approve
|
||||
|
||||
cd ../..
|
||||
|
||||
until kubectl get deployment local-registry -n container-registry -o jsonpath='{.status.availableReplicas}' 2>/dev/null | grep -q '^[1-9]'; do
|
||||
echo "Waiting for local-registry pods to initialize..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
docker buildx build \
|
||||
--network host \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t "127.0.0.1:30500/php-website:latest" \
|
||||
-f apps/website/Dockerfile \
|
||||
apps/website/ \
|
||||
--push
|
||||
|
||||
kubectl patch application php-web-app -n argocd --type merge -p '{"metadata":{"annotations":{"argocd.argoproj.io/refresh":"sync"}}}'
|
||||
|
||||
echo "Deployment successfully completed!"
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +77,9 @@ nuke() {
|
|||
sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
|
||||
EOF
|
||||
|
||||
docker buildx rm lab-builder 2>/dev/null || true
|
||||
rm -f /tmp/buildx-config.toml || true
|
||||
|
||||
echo "--> Deleting OpenTofu tracking state files..."
|
||||
rm -rf bootstrap/cluster/terraform.tfstate*
|
||||
rm -rf bootstrap/cluster/.terraform/
|
||||
|
|
|
|||
Loading…
Reference in New Issue