DevOps Flashcards
Continuous Intergration
Continuous integration (CI) is the automated process of integrating code from potentially multiple sources in order to build and test it: Unit, Servicers/API, Functional/GUI (UI interaction tests…like Capybara?). Continuous Integration is a development practice that ensures your application is always in a “good” state.
Gets triggered by source code commits
Runs any tests for frontend or backend code
Builds any artifacts (production js files, rails assets)
Publishes the artifacts (test results to dashboard, or assets to S3)
Triggers a deploy (in Opsworks)
Many CI systems are configured by a config file in the source code repo
Can build multiple branches and only deploy specific branches to specific environments
Continuous Delivery/Deployment
Continuous Delivery is an automated way to deploy your application to an environment. This can involve a number of automated or manual steps, including more integration testing, performance testing, or manual testing. The level of automation involved depends on your needs.
This includes setting up brand new environment and getting the code from the repository to the creation of fully tested and verified distribution.
Your software is deployable throughout its life-cycle
Your team prioritizes keeping the software deployable over working on new features
Anybody can get fast, automated feedback on the production readiness of their systems any time somebody makes a change to them
You can perform push-button deployments of any version of the software to any environment on demand
Continuous Deployment means that every change goes through the pipeline and automatically gets put into production, resulting in many production deployments every day.
Continuous Delivery just means that you are able to do frequent deployments but may choose not to do it, usually due to businesses preferring a slower rate of deployment. In order to do Continuous Deployment you must be doing Continuous Delivery.
Describe CI/CD pipeline
Your CI pipeline is usually triggered when code is checked into an integration branch by a developer. Unit tests are run to ensure basic functionality is correct, and then, binaries are built. The binaries created could be a JAR or Zip file or even a Docker container.
The CD can be triggered after a successful build, or it can be timed. Typically, for dev environments, your CD pipeline will be triggered by every successful build. Deployment to production can be an automatic process or can require manual sign off.
What is the point of CI/CD?
Instead of writing an entire app and investing a lot of time debugging , CI/CD automates the process as we develop. Saves lots of time. Speeds up onboarding too!
Describe CI/CD bet practices?
It should run the tests after every commit.
A single Process
Remember: when declaring variables, we are allocating a small space in RAM*
- Each process has its own ID (PID - process ID)
- Programs you write are typically “interpreted”
- For even high level languaes, the source code is written in C. (including system calls that ask to accolate memory)
- Alternatively, “compiled” programs are usually written in C (or C++)
- A program written in C has to make system calls (eg. malloc) to interact with system resources
- the vendor of os needs to supply an interface ?
- System calls are functions that the operating system is required to provide in the C language (glibc)
Processes as a tree
1
Processes - As a tree
- Not a list, they are heirarchical
- if you shut the terminal, outer process will stop too ?
- Everything ultimately becomes a child of Process 1
Processes - Interation
Processes - Interaction
- System Calls to access resources
- Environment Variables are static over process lifetime
- always available
- Stdin, Stdout, Stderr are ways to accept text input from a keyboard, and write text output to a screen
- one pipe in, 2 pipes out.
- stdin = typing on a terminal and submitting
- stdout = whatever the output is
- we can chain stdin and stdout
- Signals are ways for outside processes to trigger your process, similar to an event listener.
- ctrl + C/kill utilzies OS concept - Signal. (siginterrupt)
- interrupts the process and indicates wether or not it received the signal.
- ctrl + D kills the os. Stops the processes at once.
- Optionally, the process can ask the OS for access to the networking interface, which will assign a port number to your process.
- To enable networking, process has to make a system call that enables next network socket.
- Port ultimately gives you access to the network.
- Warcraft vs Slack? Which packet belongs to which port?
Networking
#Networking: *OSI Stack - common internet stack: 7 layers*
This is the network layer. It gives us our IP address.
- Each process can open 1 or more ports
- Not confined to just one port*
- Ports determine which process will receive an inbound packet.
- Ports are either TCP or UDP
- TCP: stateful, always guaranteed to know if the message makes it. (everything not streaming-like)
- UDP: sends, doesnt not guaranteed knowledge if msg makes it. (video streaming)
- Each network device has a MAC address
- A hardcoded ID - relatively random. No structure for addressing scheme.
- We look up to the next layer: IP address
- Any connected device also has an IP address
- We can have 2 IP addresses. The cable and the wifi.*
- You only get an IP addy from someone else.
- IP Routing:
- Modem is given its IP by whatever its connected to
- our IP is relatively close to our neighbor
- from 0:0:0:0 to 255:255:255:255
- split up jurisdiction oer a range on IP addys.
- servers that reside under our street corner, it will have its own unique IP.
- addy is like the front door to our house, we only have one. (192 - 196)
- “NATS”
- ISP divvies out pipes
- be very familiar with IP addresses*
- Networking: DNS
- DNS maps a human readable domain to an IP address.
- DNS is a global directory
- DNS is hierarchical
- Domains can have subdomains as children
- The root of this tree are the 13 root-servers
- Multiple domains may map to the same IP address
- Per DNS request, only 1 IP response
Networking: UrL
- protocol = language/format (http, email, etc)
- post number
- Full URL includes password, port, path etc.
- combines all this information into one address.
What is a continuous integration server?
Jenkins: an open source tool written in Java with plugins built for CI. Plugins allow integrations at various DevOps stages.
What is a continuous integration server?
Jenkins: an open source tool written in Java with plugins (over 1000) built for CI. Plugins allow integrations at various DevOps stages.
What is a continuous integration server?
Jenkins: an open source tool written in Java with plugins (over 1000) built for CI. Plugins allow integrations at various DevOps stages.
Its the most widely accepted tool because of its flexibility and abundance of plugins
What is a continuous integration server?
Jenkins: an open source tool written in Java with plugins (over 1000) built for CI. Plugins allow integrations at various DevOps stages.
Its the most widely accepted tool because of its flexibility and abundance of plugins. These plugins can help meet the individual needs of individual devs.
When devs make a change to the source code in the repo, the Jenkins server pulls the code and tries to make a build.
Build application is now deployed onto the test server for testing.
Now devs will be constantly notified of results.
What are shortcomings of using a single Jenkins server?
1) if you need IE tests, we need to run a Windows machine.
2) another build job may require another Linux box
Solution!
Jenkins distributed architecture.
What are shortcomings of using a single Jenkins server?
1) if you need IE tests, we need to run a Windows machine.
2) another build job may require another Linux box
Solution!
Jenkins distributed architecture.
Jenkins master distributes workload to the slaves.
Slaves provide the required environment
AWS
- AWS allows you to get access to computing hardware, and pay per hour: A physical or virtual machine
- They offer many different machine sizes (different resource allocations) at different pricing rates
- On top of this base offering, there are many different services available
- Other services though are typically just convenience or utility on top of these servers
- S3 is a little different, its storage that’s pay per data transfer, and storage used. One big file storage system.
- Most AWS services use open source technology at their core
Regions
- Everything (except S3) in AWS is specific to a region
- AWS has data centers across the world and each is managed independently
- For us in California, there are 2 data centers close to us
- Of these 2, Oregon (us-west-2) is the cheapest (over N. California). Use Oregon server.
- Make sure to always double check your region when you log in
- There could be pricing differences between regions
EC2 - Instances
Instance is the primary location to look at the state of the machines you’re using.
There are machines optimized by memory consumpton
IAM role
EC2 - KeyPairs
SSH = secure shell that uses encryption;
EC2 uses SSH keys to grant you access to the instances you create
On new instance creation, you’ll be asked to select a key
You can upload an existing public key, to which you have the private (~/.ssh/id_rsa.pub)
Or allow AWS to create a new one, and download the private key
generate by typing into the CLI: open ssl genrsl
EC2 -VPCs
- VPCs are analogous to an office network
- Faster way for machines to communicate with each other: a new IP address that is used locally?
- Inside the VPC, machines can access each other via an internal IP
- Outside, machines are accessible according to sec group rules
- We will be using the default VPC setting for all of the exercises
- Once we pass through one iteration of a CI cycle. We could use a new VPC to use as an instance that we can test?
RDS (Relational DB Service):
- RDS is a utility to automatically setup an EC2 instance, with a database service running on it
- RDS offers Mysql, Postgres, Oracle, SQL Server and others
- RDS also enables you to configure the database settings via the UI
- Big companies create a backup/snapshot that takes a copy of all data and make it into a text file.
- RDS can also be used for common database maintenance tasks, such as backups, creating slave dbs, or restoring snapshots.
- Only supports relational DBs like SQL.
EC2 - Volumes (EBS)
- Storage on these machines:
- Its like an external hard drive that can attached to any of the instances. We can only plug it in one machine at a time.
- By default, instances created are completely clean, and any data stored will not persist are machine termination
- You can add persistent storage to any instance using EBS Volumes (we dont want to lose data if machine shuts off…I think)
- Volumes will be auto-mounted in ubuntu under /mount/
- A volume can only be attached to a single instance at a time
- We will not be using EBS storage during our exercises
EC2 - Load Balancers
- AWS offers load balancers known as ELBs
- Located in the “Listeners”.
- ELBs allow you to add instances to the pool of machines
- Many services integrate with ELBs and will auto-add
ELBs allow you to configure request routing via inbound port/protocol and output port/protocol - ELBs can automatically check the health of an instance by requesting a configurable URL and considering 2XX status code healthy
EC2 - Security Groups
- All instances we create have security rules. Kind of like firewalls. If we connect to our machine, there’s a chance that we are being blocked by the Security group.
- Security Groups are applied to all instances and ELBs
- They are similar to a firewall, and restrict all traffic destined to that machine according to configurable rules: (SSH, Custom TCP rule. In inbound security groups).
S3
- S3 is a distributed file storage system
- You can upload files via the AWS API
- Files can be private or public
- S3 is outside of region settings
- These are static files.
Cloudfront
- Cloudfront is a distributed CDN (Content Delivery Network)
- It is outside of region settings
- Can be configured to serve content from an application server or an S3 bucket
- Can be configured to use a custom domain
- Expiry/Invalidation of cached content can be configured
- Invalidation can also be caused by API
Certificate Manager
- The certificate manager stores any SSL certificates that you wish to use in other AWS services
- We will be using this to enable HTTPS in our application
Route 53
- Route 53 is a domain name manager
- You can register new domains, or transfer existing domains to AWS nameservers
- Once you have a domain hosted on AWS, you can configure DNS records for the domain
- Route 53 integrates gracefully with other AWS services, allowing you to do things that would be difficult on other hosting platforms (geodns, elb)
Cloudwatch
Cloudwatch is used to monitor the health of your servers
Makes sure website is up, working.. the goal is to get to the bugs before the users get them.
Monitored resources include:
CPU
RAM
Network
Hard Disk
“Alerts” are configurable in the AWS UI
Alerts notify devs by email when resource usage passes given thresholds
Can be integrated with other notification services (PagerDuty)
Opswork
Opsworks enables the automation of machine configuration
IT orchestration or IT automation
Uses “Layers” to specify roles for each machine
Can use chef or puppet to author setup scripts
Scripts get triggered by instance lifecycle events
Deployment scripts can be triggered by API
Integrates well with other AWS services
More detail to come!