diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..3931a9c11 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:1.23 as base + +WORKDIR /app + +COPY go.mod . + +RUN go mod download + +COPY . . + +RUN go build -o main . + +# Final stage + +FROM gcr.io/distroless/base + +COPY --from=base /app/main . + +COPY --from=base /app/static /static + +EXPOSE 8080 + +CMD [ "./main" ] + + + + diff --git a/helm/go-web-app-chart/.helmignore b/helm/go-web-app-chart/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/helm/go-web-app-chart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/go-web-app-chart/Chart.yaml b/helm/go-web-app-chart/Chart.yaml new file mode 100644 index 000000000..5d5e4a81b --- /dev/null +++ b/helm/go-web-app-chart/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: go-web-app-chart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/helm/go-web-app-chart/templates/deployment.yaml b/helm/go-web-app-chart/templates/deployment.yaml new file mode 100644 index 000000000..26e715384 --- /dev/null +++ b/helm/go-web-app-chart/templates/deployment.yaml @@ -0,0 +1,22 @@ + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + replicas: 1 + selector: + matchLabels: + app: go-web-app + template: + metadata: + labels: + app: go-web-app + spec: + containers: + - name: go-web-app + image: jansoltys9/go-web-app:{{ .Values.image.tag }} + ports: + - containerPort: 8080 diff --git a/helm/go-web-app-chart/templates/ingress.yaml b/helm/go-web-app-chart/templates/ingress.yaml new file mode 100644 index 000000000..75e4c194e --- /dev/null +++ b/helm/go-web-app-chart/templates/ingress.yaml @@ -0,0 +1,22 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: go-web-app + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: ae2f2e85dc53741288320c8fcc2c6ae1-6b1edc01172d2943.elb.us-east-1.amazonaws.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: go-web-app + port: + number: 80 + + + \ No newline at end of file diff --git a/helm/go-web-app-chart/templates/service.yaml b/helm/go-web-app-chart/templates/service.yaml new file mode 100644 index 000000000..3029e0d3f --- /dev/null +++ b/helm/go-web-app-chart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + ports: + - port: 80 + targetPort: 8080 + protocol: TCP + selector: + app: go-web-app + type: ClusterIP + + diff --git a/helm/go-web-app-chart/values.yaml b/helm/go-web-app-chart/values.yaml new file mode 100644 index 000000000..a4cae5433 --- /dev/null +++ b/helm/go-web-app-chart/values.yaml @@ -0,0 +1,123 @@ +# Default values for go-web-app-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: nginx + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "v1" + +# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +#This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +#This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s/manifests/deployment.yaml b/k8s/manifests/deployment.yaml new file mode 100644 index 000000000..ce62222f6 --- /dev/null +++ b/k8s/manifests/deployment.yaml @@ -0,0 +1,22 @@ + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + replicas: 1 + selector: + matchLabels: + app: go-web-app + template: + metadata: + labels: + app: go-web-app + spec: + containers: + - name: go-web-app + image: jansoltys9/go-web-app:v1 + ports: + - containerPort: 8080 diff --git a/k8s/manifests/ingress.yaml b/k8s/manifests/ingress.yaml new file mode 100644 index 000000000..75e4c194e --- /dev/null +++ b/k8s/manifests/ingress.yaml @@ -0,0 +1,22 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: go-web-app + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: ae2f2e85dc53741288320c8fcc2c6ae1-6b1edc01172d2943.elb.us-east-1.amazonaws.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: go-web-app + port: + number: 80 + + + \ No newline at end of file diff --git a/k8s/manifests/service.yaml b/k8s/manifests/service.yaml new file mode 100644 index 000000000..3029e0d3f --- /dev/null +++ b/k8s/manifests/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: go-web-app + labels: + app: go-web-app +spec: + ports: + - port: 80 + targetPort: 8080 + protocol: TCP + selector: + app: go-web-app + type: ClusterIP + + diff --git a/main b/main new file mode 100644 index 000000000..fc088a328 Binary files /dev/null and b/main differ