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.

Gophercon 2018: Kubernetes api golang

This talk aims to introduce basic terms and explore best practices for developing Kubernetes native applications using client-go

Code can be found here:

  • Be the first to comment

  • Be the first to like this

Gophercon 2018: Kubernetes api golang

  1. 1. Gophercon Pune 2018 Using Kubernetes API effectively with Golang
  2. 2. Vishal Biyani CTO & Founder at InfraCloud technologies GDE: Google Developer Expert - Kubernetes, Google Cloud Kubernetes Pune Meetup Organizer Serverless Pune meetup Organizer Fission contributor (FaaS on Kubernetes)
  3. 3. Tomorrow 11:45 AM Playing with robots in Golang
  4. 4. Do you use Kubernetes? Do you develop applications which extend Kubernetes’s capability? Quick question
  5. 5. 1) Introduce vocabulary (What is a controller, indexer?) 2) Explore best practices .. For developing Kubernetes native applications Goals
  6. 6. Find code here: gopherconindia2018
  7. 7. Library structure ● Scheme & encoding/decoding packages for Kubernetes API objects ● Client code - Most of times you will deal with tools/cache package
  8. 8. Codetime: “Hello World” ● Authenticating with Kubernetes Cluster ○ From outside cluster ○ In Cluster: ● Basic CRUD Demo 1 *RBAC*
  9. 9. Kubernetes Controller ● Active Loop { desired state → Current state } for { desired := getDesiredState() current := getCurrentState() makeChanges(desired, current) }
  10. 10. ListWatcher: List objects and watch based on resource version Building Blocks Demo 2
  11. 11. Store: A way to store objects locally Indexer: Store, with multiple indexing functions Building Blocks
  12. 12. Workqueue: Provide work items in order only once, in multiple consumer/producers RateLimitingQueue: Limit addition rate DelayingQueue: Failed, try after X Building Blocks
  13. 13. Building Blocks Informer: events for changes in objects SharedInformer: Mutiple event handlers for a change Reflector: Watches a ListWatcher and updates data in Store on change
  14. 14. More codetime
  15. 15. Kubernetes is a distributed System
  16. 16. Queue items and use multiple workers to pick items from queue to operate on Queue & operate
  17. 17. On error retry with reasonable backoff and then percolate error to top level On error, requeue + retry, then error
  18. 18. Order No latency Not missing events Don’t assume
  19. 19. When in doubt Check resource version of Object, if it has not changed, nothing has changed.
  20. 20. Object relations If X creates Y, then use OwnerReference (Pod’s owner reference is ReplicationController)
  21. 21. There are multiple actors and current state might be changed by others too! Multiple actors
  22. 22. ● Controllers Doc: ster/contributors/devel/ ● Sample controllers built in Calico: ee/master/pkg/controllers ● Alena’s talk at Kubecon US 2017: Learn more:
  23. 23. ধন বাদ! Dank je! Kiitos! આભાર! ध यवाद! Grazie! Je vous remercie! ありがとうございました! ਤੁਹਾਡਾ ਧੰਨਵਾਦ! ந றி! ధన ా ల ! ന ി! THANK YOU!