1 of 32

Infrastructure CI/CD using �Open Source Tools

A Simple approach on how world does it

Darshit Suratwala

DevOps @ Scale3

Mumbai

Darshit Suratwala

DevOps @ Scale3

2 of 32

Agenda

  • Intro To Tools
  • Workflow
  • Demo

3 of 32

Why This Talk?

  • Everyone wants to be in cloud
  • Control the resources which are created

But most importantly…

4 of 32

Understand!

Why it’s done?

How it’s done?

5 of 32

So you may ask what do we want to understand?

6 of 32

The Process

The Purpose

7 of 32

Scenario

Imagine a simple scenario where your client asks you to create a server on GCP, how would you do it?

8 of 32

Possible solution 1

Login to google cloud platform and follow the documentation to create a Compute Engine VM.

9 of 32

Possible solution 2

Write a Selenium script to automatically login to GCP and create VM.

10 of 32

Possible solution 3

Write a script to consume GCP APIs in your choice of programming language or use gcloud cli to create a desired VM.

11 of 32

Scenario

Imagine a simple scenario where your client asks you to create a server on GCP, how would you do it?

Update:

Add Labels to server

12 of 32

Scenario

Imagine a simple scenario where your client asks you to create a server on GCP, how would you do it?

Update:

Add Labels to server

Update:

Do it for 500 servers.

13 of 32

If you do it programmatic way

  • Its difficult to identify which servers were created by you.
  • Lot of exception handling,
    • Someone deletes the server
    • Server was modified
    • And many unknowns
  • Time

14 of 32

Infrastructure as Code (IaC)

Managing infrastructure using configs or code instead of through a manual process.

Examples:

  • Deployment Manager
  • Ansible
  • CloudFormation
  • Terraform
  • Chef
  • Pulumi

15 of 32

16 of 32

17 of 32

So first we will go through some basics of

  1. Terraform
  2. GitHub Actions
  3. Slack

18 of 32

Let’s Get Started with Terraform …

19 of 32

Terraform CRUD

  1. Plan
  2. Apply
  3. Delete

It’s an open source IaC tool!

Users define config files for provisioning infrastructure.

20 of 32

> terraform plan

It shows you the blueprint of what’s going to happen.

21 of 32

> terraform apply

Performs the actions which were proposed by the plan.

Actions can be:

  • Create new resource
  • Update existing resource
  • Delete the resource
  • Replace the resource

22 of 32

Let’s talk state!

  • What are state files?
    • Map of real world resources

  • What benefits they bring on table?
    • Everything is persisted which means you can revisit anytime.
    • Enables cross collaboration

23 of 32

> terraform destroy

Similar to apply, but deletes the resources which are present in state file.

24 of 32

Lights

Camera

Github Actions!

25 of 32

GitHub Actions

  • How it works: creates a VM underlying for us to run code
  • How it triggers:
    • Manual using API/UI
    • Automatically by specifying triggers
  • It’s free for public projects!

26 of 32

Let’s see GitHub Actions in Action

27 of 32

Notifications

28 of 32

Slack Notifications: Why? What? How?

Why�Notifies when deploy finishes�Useful for approval mechanism

What�Using Slack APIs send messages on channels or DMs.

How�Consume Slack Bot token in your code to send notifications

29 of 32

30 of 32

Demo Time!

References

31 of 32

Conclusion

  • This talk was an example how one can setup CI/CD system using one of the tools in each category.
  • In professional work, companies or clients have their own preference/choice of CI/CD systems, but the concept remains the same everywhere.

32 of 32

That’s All Folks!

/DSdatsme