My name is Nikita and I am a systems engineer at SEMrush. And in this article I will tell you what Immutable Infrastructure is, what advantages and disadvantages this approach has, and how we use it in the company.
If you have never heard such a phrase, then sit back, it will be interesting.
What it is
Immutable Infrastructure β . , . , , Kubernetes, .
, "" . , β . , "" . , .
, .
GCP, ββ, . GCP API SaaS , Immutable . KVM-, , . (Openstack, AWS, Azure ..), . , , , POST-, .
Immutable
, Docker Kubernetes, , :
-
, . - , β β : - , security , . ββ . . Immutable Infrastructure , --. : , . , . -
Immutable infrastructure , () , CI/CD. . -
Docker , . - configuration management unattended upgrades, . . , , , . , . - configuration drift
, 100 , , - . , . unattended upgrade, , - , - . Immutable , , , . -
, . , . Immutable . , . failure point , , - production VM. , , , , . -
Immutable "" , , . β . -
, . -
, CPU RAM, . , GCP: Load balancers, GCS , Autoscaler, Cloud SQL .. -
, , β , . , immutable. "" . , . -
, . , . Docker . -
, . . -
Dev . , ( provisioner) Prod .
, , . Immutable . , , , , , .. Immutable.
-
Immutable , , . ( , , ..). . . -
, - , , : , , , . , ( , , , Immutable ). : storage. , (, ), storage ( downgrade ). . Stateless , . , , SLA, . -
, Immutable β , security .., . , .
. Immutable , , , , , .. - ( ), . Immutable Immutable. , . .
Push Pull
, . :
Push
, , , . , β , , CI/CD , . β .
Pull
, ( ). , , CI. . β ( ).
- CI/CD .
:
- Packer β Hashicorp, , . Packer , , , , .
- Terraform β Hashicorp, , , . , , .
- Ansible β , . , provision β .
- Gitlab CI β Gitlab, .
- GCP β , , , .
Immutable Images
VM . , Google, , - , (nginx, mysql, mongodb ..), . ( , -, ). , - . ( ) Ansible β , one-shot .
, . , , (, ), . .
Image Family
GCP , , , - Image Family.
Image Family β , "". β , , , .., image family, , . latest .
, Image Family , Image Name , ( ). latest , family .
Image Family :
image-v1 β . my-image-family
gcloud compute images create image-v1 \
--source-disk disk-1 \
--source-disk-zone us-central1-f \
--family my-image-family
gcloud compute images describe-from-family my-image-family
family: my-image-family
id: '50116072863057736'
kind: compute#image
name: image-v1
image-v2, my-image-family .
gcloud compute images create image-v2 \
--source-disk disk-2 \
--source-disk-zone us-central1-f \
--family my-image-family
gcloud compute images describe-from-family my-image-family
family: my-image-family
id: '50116072863057756'
kind: compute#image
name: image-v2
- , my-image-family image-v1:
gcloud compute images deprecate image-v2 \
--state DEPRECATED \
--replacement image-v1
gcloud compute images describe-from-family my-image-family
family: my-image-family
id: '50116072863057736'
kind: compute#image
name: image-v1
. , ? , , .. - , .
GCP :
READY β
DEPRECATED β deprecated. - -, gcloud terraform. .
OBSOLETE β .
DELETED β , .
REALLY_DELETED β , , DELETED, -.
, . .
. , . , image-family . , image-family.
image-rotator, ( ). :
- ,
--image-family
. , - , Image Family, , Image Family
- :
- READY DEPRECATED , OBSOLETE
- DEPRECATED , obsolete , OBSOLETE , DELETED
- OBSOLETE DEPRECATED
- DELETED. DELETED ,
, , , .
, , .
, Dev- Master- ( ), . , Prod- β stable, Merge Request.
. , , , :
- Hashicorp Vault
- Prod- Dev
- CloudSQL (: Google (MySQL, PostgreSQL)) Prod- Dev-
- Dev- ( , )
Terraform Dev-, , .1. , . ββ Prodβ :)
. ( , ), , , , , . , /, , : , CI/CD . .
Immutable Infrastructure β , . , . , , . , . - , .
, , , , , . , , .