Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Declare your infrastructure: InfraKit, LinuxKit and Moby

1,502 views

Published on

InfraKit is a toolkit for infrastructure orchestration. With an emphasis on immutable infrastructure, it breaks down infrastructure automation and management processes into small, pluggable components. These components work together to actively ensure the infrastructure state matches the user's specifications. InfraKit therefore provides infrastructure support for higher-level container orchestration systems and can make your infrastructure self-managing and self-healing.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Declare your infrastructure: InfraKit, LinuxKit and Moby

  1. 1. Declare Your Infrastructure InfraKit, LinuxKit, and Moby Steven Kaufer, David Freitag – IBM Cloud
  2. 2. Infrakit Agenda Why Infrakit + Terraform? Terraform Instance Plugin Overview Topology Example Swarm Cluster Bootstrapping
  3. 3. Why Infrakit + Terraform? Terraform - Manages declarative infrastructure (as code) - Broad platform coverage - Focuses on initial deployment Infrakit - Active monitoring - Enforcement of declarative specifications - Group abstraction
  4. 4. Infrakit Terraform Instance Plugin • Each instance defined in unique tf.json file • Files built from a common instance specification with unique attributes • Update = File removal (destroy) + replacement (provision) $ ls instance-1507652020.tf.json instance-1507652021.tf.json instance-1507652022.tf.json terraform.tfstate { "resource": { "ibm_compute_vm_instance": { "instance-1507652020": { "cores": 2, "hostname": "worker-1507652020", "tags": [ "infrakit.group:workers", "name:instance-1507652020" ... } tf.json instance-1507652020.tf.json
  5. 5. Topology Example Node 1 Node 2 Node 3 $ ls instance-1.tf.json instance-2.tf.json instance-2.tf.json
  6. 6. Topology Example Block Storage 1 Block Storage 2 Block Storage 3 Node 1 Node 2 Node 3
  7. 7. Topology Example Network File Storage Block Storage 1 Block Storage 2 Block Storage 3 Node 1 Node 2 Node 3
  8. 8. Topology Example Network File Storage Block Storage 1 Block Storage 2 Block Storage 3 Node 1.1 Node 1 Node 2 Node 3
  9. 9. Topology Example Network File Storage Block Storage 1 Block Storage 2 Block Storage 3 Node 1.1 Node 1 Node 2 Node 3 • Where is the block and network storage defined? • How can node x reference the related resources?
  10. 10. Solution – Resource Scoping Network File Storage Block Storage 1 Block Storage 2 Block Storage 3 Node 1.1 Node 1 Node 2 Node 3 Dedicated Scope - Re-attach on rolling update Global Scope - Tied to group lifecycle
  11. 11. Solution – Resource Scoping Network File Storage Block Storage 1 Block Storage 2 Block Storage 3 Node 1.1 Node 1 Node 2 Node 3 Dedicated Scope - Re-attach on rolling update Global Scope - Tied to group lifecycle
  12. 12. Resource Scoping - Use @scope resource property - dedicated: Loosely coupled with VM - global: Coupled with the scope (group) { "Allocation": { "LogicalIDs": ["mgr1", "mgr2", "mgr3"] }, "Instance": { "Plugin": "instance-terraform", "Properties": { "resource": { "ibm_compute_vm_instance": { "host": {...} }, "ibm_storage_file": { "my_file_storage": { "@scope": "managers", ... } } "ibm_storage_block": { "my_block_storage": { "@scope": "@dedicated-managers", ... } }, ... $ ls instance-xxx1.tf.json instance-xxx2.tf.json instance-xxx3.tf.json managers_dedicated_mgr1.tf.json managers_dedicated_mgr2.tf.json managers_dedicated_mgr3.tf.json managers_global.tf.json @scope
  13. 13. Resource Scoping Reference related resource using terraform interpolation - Predicable “type.name.attribute” path: - Global: - Dedicated quorum: - Dedicated scaler: ${ibm_storage_file.managers-my_file_storage.id} ${ibm_storage_block.workers-{{ var "/self/dedicated/attachId" }}-my_block_storage.id} <resource-type>.<scope>-[<logicalID|index>-]<given-resource-name>.<attribute> [----------------resource-name------------------] ${ibm_storage_block.managers-{{ var "/self/logicalId" }}-my_block_storage.id}
  14. 14. Resource Scoping Demo
  15. 15. Swarm Cluster Bootstrapping Network File Storage Mgr-1 Goals: - Infrakit running on each swarm manager - Shared terraform files on NFS - Self-healing and self-managing with leadership failover Mgr-2 Mgr-3 InfraKit
  16. 16. Mgr-1 Bootstrap Flow: 1. Create seed VM in IBM Schematics SeedVM Swarm Cluster Bootstrapping
  17. 17. Swarm Cluster Bootstrapping Network File Storage Mgr-1 Bootstrap Flow: 1. Create seed VM in IBM Schematics 2. Mount NFS SeedVM
  18. 18. Swarm Cluster Bootstrapping Network File Storage Mgr-1 Bootstrap Flow: 1. Create seed VM in IBM Schematics 2. Mount NFS 3. Import current VM and NFS into TF and create import tf.json files SeedVM InfraKit tf.json
  19. 19. Swarm Cluster Bootstrapping Network File Storage Mgr-1 Bootstrap Flow: 1. Create seed VM in IBM Schematics 2. Mount NFS 3. Import current VM and NFS into TF and create import tf.json files 4. Scale out group SeedVM Mgr-2 Mgr-3 InfraKit tf.json
  20. 20. Bootstrapping Resources - Define resource(s) in plugin.config file - Imports resources into terraform state - Creates tf.json files "inproc": { "Kind": "terraform", "Options": { "ImportResources": [ { "ResourceType": "ibm_compute_vm_instance", "ResourceID": "<vm-id>" }, { "ResourceType": "ibm_storage_file", "ResourceID": "<file-storage-id>" } ] } } tf.json plugin.config plugin.config
  21. 21. Group Bootstrapping Demo
  22. 22. Thanks! Declare Your Infrastructure InfraKit, LinuxKit, and Moby
  23. 23. Resource Scoping Demo Backup # cat instance-1507834700.tf.json { "resource": { "ibm_compute_vm_instance": { "instance-1507834700": { "cores": "2", "datacenter": "dal10", "memory": "2048", "tags": [ "swarm-id:jwd0s2qozy4re26mbx0zcvj42", "infrakit.attach:workers_dedicated_1 workers_global", "name:instance-1507834700", "infrakit-link:rmncsfzc6l3f23nn", "infrakit-link-context:swarm::jwd0s2qozy4re26mbx0zcvj42::worker", "infrakit-link-created:2017-10-12t18:58:20z", "infrakit.config_sha:s3yqjs7hpijtxue5l2tbudqxq5dgkwhh", "infrakit.group:workers" ], "user_metadata": "echo NFS-ID: ${ibm_storage_file.workers-my_file_storage.id} BS-ID: ${ibm_storage_block.workers-1-my_block_storage.id} ... "
  24. 24. Resource Scoping Demo Backup # infrakit group/workers describe ID LOGICAL TAGS instance-1507652020 - infrakit.attach=workers_dedicated_1,workers_global instance-1507652021 - infrakit.attach=workers_dedicated_2,workers_global instance-1507652022 - infrakit.attach=workers_dedicated_3,workers_global # terraform show ibm_compute_vm_instance.instance-1507652020: id = 41638329 tags.1986196614 = infrakit.attach:workers_dedicated_1 workers_global user_metadata = echo NFS-ID: 32062003 BS-ID: 32062011 ibm_compute_vm_instance.instance-1507652021: id = 41639325 tags.1604993140 = infrakit.attach:workers_dedicated_2 workers_global user_metadata = echo NFS-ID: 32062003 BS-ID: 32062595 ibm_compute_vm_instance.instance-1507652022: id = 41640617 tags.4056076773 = infrakit.attach:workers_dedicated_3 workers_global user_metadata = echo NFS-ID: 32062003 BS-ID: 32062597 ibm_storage_block.workers-1-my_block_storage: id = 32062011 ibm_storage_block.workers-2-my_block_storage: id = 32062595 ibm_storage_block.workers-3-my_block_storage: id = 32062597 ibm_storage_file.workers-my_file_storage: id = 32062003

×