Skip to content

Kustomization

Deployment

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vm-tracker-api
  labels:
    app: vm-tracker-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: vm-tracker-api
  template:
    metadata:
      labels:
        app: vm-tracker-api
    spec:
      containers:
      - env:
        - name: API_BASE_URL
          value: "https://vm-tracker.example.com"
        - name: BASE_URL
          value: "https://vm-tracker.example.com"
        - name: LIST_URL
          value: "/api/vms"
        - name: REGISTER_URL
          value: "/api/register"
        - name: DELETE_BASE_URL
          value: "/api/vms/"
        name: vm-tracker-api
        image: ghcr.io/9it-full-service/vm-tracker-api:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          protocol: TCP
          name: http
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "500m"
service.yaml
apiVersion: v1
kind: Service
metadata:
  name: vm-tracker-api-service
  labels:
    app: vm-tracker-api
spec:
  type: ClusterIP
  ports:
  - port: 8080
    targetPort: 8080
    protocol: TCP
    name: http
  selector:
    app: vm-tracker-api
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/cluster-issuer: clusterissuer
  name: vm-tracker-ingress
spec:
  ingressClassName: traefik
  rules:
  - host: vm-tracker.example.com
    http:
      paths:
      - backend:
          service:
            name: vm-tracker-api-service
            port:
              number: 8080
        path: /
        pathType: Prefix
  tls:
    - hosts:
        - vm-tracker.example.com
      secretName: vm-tracker.example.com-tls
kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml
  - service.yaml
  - ingress.yaml

namespace: vm-tracker

Execute Kustomization

kustomization build . > k8s-vm-tracker.yaml

Install in Kubernetes

kubectl apply -f k8s-vm-tracker.yaml