Skip to content
/ store-cd Public

This demo shows application and infrastructure deploy using YC, Terraform, k8s, Helm and monitoring with Prometheus, Grafana. Part 2

Notifications You must be signed in to change notification settings

wkwwa/store-cd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

demo app - developing with k8s and Gitlab CI/CD

image

This demo contains the code for delivering and deploying the infrastructure for an online store.

This stage is the second stage of a full application build-delivery cycle, using CI/CD practices.

The build and release stage is described here

CD is implemented through a Downstream Pipeline, in which three child pipelines will be executed:

  • Deploying Yandex Cloud and creating a Managed Service for Kubernetes cluster using Terraform.

    To create a Managed Service for Kubernetes cluster, you need to prepare the infrastructure in advance:
    1. Install and initialize Yandex Cloud command line interface.
    2. Create a service account with rights to deploy to the cloud in the directory where the Kubernetes cluster is being created. Resources needed by the Kubernetes cluster will be created on behalf of this account.
      # Получение идентификатора облака
      yc resource-manager cloud list
      
      # Получение идентификатора каталога
      yc resource-manager folder list
      
      yc iam service-account create --name service-tf
      yc resource-manager folder add-access-binding <folderID> --service-account-name service-tf --role editor
      
    3. Create an authorization key for the service account.
      yc iam key create \\
          --service-account-name service-tf \\
          --output sa-key.json
      
    4. Add the key output to the GitLab CI/CD variables: $YC_KEY
      cat sa-key.json | pbcopy
      
    5. Create a service account with write permissions to the storage and an authorization key for the S3 bucket and YDB table to load Terraform states.
      yc iam service-account create --name service-s3-ybd
      yc resource-manager folder add-access-binding <folderID> --service-account-name service-s3-ybd --role storage.uploader
      yc resource-manager folder add-access-binding <folderID> --service-account-name service-s3-ybd --role ydb.editor
      yc iam access-key create --service-account-name service-s3-ybd
      
    6. Add the key output to the GitLab CI/CD environment variables: $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
    7. Create an S3 bucket and a YDB table.
    8. Edit the terraform/provider.tf file, specifying the parameters for connecting to the cloud, S3, and YDB.
  • Deploying the online store is done by installing a Helm package, which, after building the chart, is published and stored in the Nexus repository. The chart contains 2 subcharts: frontend and backend, which use the image of previously prepared containers from a private repository in Gitlab.

  • Deploying monitoring tools Prometheus and Grafana is done by installing a Helm chart.

    After installation, you need to configure [Grafana](http://localhost:3000) to add Prometheus as a data source:
    1. Go to the Configuration section (the gear icon in the left menu) and select Data Sources.
    2. Add (the Add Data Source button) a data source of the Prometheus type. As a URL, you can use the address of the Kubernetes service: http://prometheus:9090.
    3. To import a dashboard into Grafana, go to the Import menu and paste the dashboard ID in the field with the title: import via grafana.com. Click the Load button.

About

This demo shows application and infrastructure deploy using YC, Terraform, k8s, Helm and monitoring with Prometheus, Grafana. Part 2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published