deployment
This commit is contained in:
		
							
								
								
									
										30
									
								
								.woodpecker.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								.woodpecker.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
steps:
 | 
			
		||||
  build:
 | 
			
		||||
    image: plugins/kaniko
 | 
			
		||||
    settings:
 | 
			
		||||
      repo: ${FORGE_NAME}/${CI_REPO}
 | 
			
		||||
      registry: 
 | 
			
		||||
        from_secret: container_registry
 | 
			
		||||
      tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
 | 
			
		||||
      username: 
 | 
			
		||||
        from_secret: container_registry_username
 | 
			
		||||
      password: 
 | 
			
		||||
        from_secret: container_registry_password
 | 
			
		||||
      build-args: "BASE_URL=https://minimal-setups.hottis.de"
 | 
			
		||||
      dockerfile: Dockerfile
 | 
			
		||||
    when:
 | 
			
		||||
      - event: push
 | 
			
		||||
 | 
			
		||||
  deploy:
 | 
			
		||||
    image: portainer/kubectl-shell:latest
 | 
			
		||||
    secrets:
 | 
			
		||||
      - source: kube_config
 | 
			
		||||
        target: KUBE_CONFIG_CONTENT
 | 
			
		||||
    commands:
 | 
			
		||||
      - export IMAGE_TAG=$CI_COMMIT_TAG
 | 
			
		||||
      - printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig
 | 
			
		||||
      - export KUBECONFIG=/tmp/kubeconfig
 | 
			
		||||
      - ./deployment/deploy.sh
 | 
			
		||||
    when:
 | 
			
		||||
      - event: push
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										59
									
								
								deployment/deploy-yml.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								deployment/deploy-yml.tmpl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
apiVersion: apps/v1
 | 
			
		||||
kind: Deployment
 | 
			
		||||
metadata:
 | 
			
		||||
  name: hugo-build-and-serve-env
 | 
			
		||||
  labels:
 | 
			
		||||
    app: hugo-build-and-serve-env
 | 
			
		||||
spec:
 | 
			
		||||
  replicas: 1
 | 
			
		||||
  selector:
 | 
			
		||||
    matchLabels:
 | 
			
		||||
      app: hugo-build-and-serve-env
 | 
			
		||||
  template:
 | 
			
		||||
    metadata:
 | 
			
		||||
      labels:
 | 
			
		||||
        app: hugo-build-and-serve-env
 | 
			
		||||
    spec:
 | 
			
		||||
      containers:
 | 
			
		||||
        - name: hugo-build-and-serve-env
 | 
			
		||||
          image: %IMAGE%
 | 
			
		||||
          ports:
 | 
			
		||||
            - containerPort: 8080
 | 
			
		||||
              protocol: TCP
 | 
			
		||||
---
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: Service
 | 
			
		||||
metadata:
 | 
			
		||||
  name: hugo-build-and-serve-env
 | 
			
		||||
spec:
 | 
			
		||||
  type: ClusterIP
 | 
			
		||||
  selector:
 | 
			
		||||
    app: hugo-build-and-serve-env
 | 
			
		||||
  ports:
 | 
			
		||||
    - name: http
 | 
			
		||||
      targetPort: 8080
 | 
			
		||||
      port: 80
 | 
			
		||||
---
 | 
			
		||||
apiVersion: networking.k8s.io/v1
 | 
			
		||||
kind: Ingress
 | 
			
		||||
metadata:
 | 
			
		||||
  name: hugo-build-and-serve-env
 | 
			
		||||
  annotations:
 | 
			
		||||
    cert-manager.io/cluster-issuer: letsencrypt-production-http
 | 
			
		||||
spec:
 | 
			
		||||
  tls:
 | 
			
		||||
    - hosts:
 | 
			
		||||
        - minimal-setups.hottis.de
 | 
			
		||||
      secretName: hugo-build-and-serve-env-cert
 | 
			
		||||
  rules:
 | 
			
		||||
    - host: minimal-setups.hottis.de
 | 
			
		||||
      http:
 | 
			
		||||
        paths:
 | 
			
		||||
          - path: /
 | 
			
		||||
            pathType: Prefix
 | 
			
		||||
            backend:
 | 
			
		||||
              service:
 | 
			
		||||
                name: hugo-build-and-serve-env
 | 
			
		||||
                port:
 | 
			
		||||
                  number: 80
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								deployment/deploy.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								deployment/deploy.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
if [ "$IMAGE_TAG" == "" ]; then
 | 
			
		||||
  echo "Make sure IMAGE_TAG is set"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
IMAGE_NAME=gitea.hottis.de/wn/hugo-build-and-serve-env
 | 
			
		||||
NAMESPACE=homepages
 | 
			
		||||
DEPLOYMENT_DIR=$PWD/deployment
 | 
			
		||||
 | 
			
		||||
pushd $DEPLOYMENT_DIR > /dev/null
 | 
			
		||||
 | 
			
		||||
kubectl create namespace $NAMESPACE \
 | 
			
		||||
  --dry-run=client \
 | 
			
		||||
  -o yaml | \
 | 
			
		||||
  kubectl -f - apply
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cat $DEPLOYMENT_DIR/deploy-yml.tmpl | \
 | 
			
		||||
  sed -e 's,%IMAGE%,'$IMAGE_NAME':'$IMAGE_TAG','g | \
 | 
			
		||||
  kubectl apply -f - -n $NAMESPACE
 | 
			
		||||
 | 
			
		||||
popd > /dev/null
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user