I ran into the word "IaaC" (or IaC) many times. When I googled it, it told me :
Infrastructure as code(IaC) is the process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools.
Can yaml files used in Kubernetes be an example of IaC? Maybe even Dockerfile can be considered as such? If not, could you give me some examples of IaC?
For example :
apiVersion: v1
kind: Service
metadata:
name: my-nginx-svc
labels:
app: nginx
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: nginx
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
There are a number of steps which a IP Ops need to do to release/update the application running on the internet. Few examples of the tasks are
Provisioning new virtual machines, like starting the VM with the required memory and specs.
Installing the required software and dependency
Managing and scaling the infrastructure.
Repeating all of the configurations we've made again and again.
Infrastructure as a code means automating the steps required to deploy our application on the internet. Since using docker and k8s we are automating the deployment process, it is also considered infrastructure as a code.
Example
# define services (containers) that should be running
services:
mongo-database:
image: mongo:3.2
# what volumes to attach to this container
volumes:
- mongo-data:/data/db
# what networks to attach this container
networks:
- raddit-network
raddit-app:
# path to Dockerfile to build an image and start a container
build: .
environment:
- DATABASE_HOST=mongo-database
ports:
- 9292:9292
networks:
- raddit-network
# start raddit-app only after mongod-database service was started
depends_on:
- mongo-database
# define volumes to be created
volumes:
mongo-data:
# define networks to be created
networks:
raddit-network:
This docker compose file installs the dependency mongo-database by itself also it installs the main application raddit-app, and specifies the port the application listens for.