Code Monkey home page Code Monkey logo

azure-k8s-service's Introduction

Azure Kubernetes Service demo

Build status

Bu repository'de Azure Kubernetes Service ile tanışalım blog yazısında anlatılan Azure Kubernetes(k8s) Service(AKS) ile ilgili örnekleri bulabilirsiniz.

ℹ Bu repository'de AKS ve Kubernetes(K8s) ile ilgili bazı konular ile ilgili temel basit örnekleri de zaman içerisinde eklemeye çalışacağım. k8s klasörü içerisinden takip edilebilir.


Güncelleme Giriş

Bu repo.'ya ev sahipliği yapan yazıda, k8s için gerekli olan bileşenleri, Azure'da portal dışında terraform gibi "infra-as-code" konsepti ile de oluşturabileceğimizi belirtmiştim. Kodlar arasında infrastructure/azure klasörü içinde Azure Kubernetes Service için örnek olabilecek kodları görebilirsiniz.

  • infrastructure/azure klasörü içerisinde terraform ile Azure Kubernetes Service içinde bir cluster oluşturmak için sırasıyla:

    • terraform init
      • "state" dosyasını Azure Storage'da tutabilmek için
        terraform init -backend=true -backend-config storage_account_name="k8sdemoresourcestfstate" -backend-config container_name="terraform-states" -backend-config access_key="" -backend-config key="terraform.tfstate"
        
        *Bu sayede terraform tarafında yapılmış değişiklikleri başka bir kişi de bu state dosyası üzerinde çalışarak yapabilir.
    • terraform plan -refresh=true
    • terraform apply -auto-approve
  • GitHub CodeSpace üzerinden geliştirme yapabilmek için, terraform, GitHub CodeSpace içerisinde kurulmalı:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
terraform -help  !!Terraform'un başarılı bir şekilde kurulduğunu anlamak için)!!
terraform -install-autocomplete !!Opsiyonel - terraform geliştirmelerini daha kolay yapmak için!!

Aynı zamanda k8s cluster'ını yönetmek ya da bazı bileşenleri oluşturmak için kubectl komutundan faydalanabiliyoruz. Benzer şekilde AKS için AZ CLI ile bazı işlemleri gerçekleştirebiliyoruz.

  • Gerektiği zaman cluster'ı durdurup, tekrar başlatmak için
az aks start --resource-group k8s-demo-resources --name k8s-cluster-01

az aks stop --resource-group k8s-demo-resources --name k8s-cluster-01
  • AKS üzerindeki cluster'ı yönetebilmek için AKS CLI'ı yüklemek için
az aks install-cli
  • Cluster'a bağlanmak için ve kubectl komutlarının AKS için çalışmasını sağlamak için
az aks get-credentials --resource-group "k8s-demo-resources" --name "k8s-cluster-01"
  • Cluster'daki node'ları listelemek için
kubectl get nodes

image

  • Bir pod'un içine girmek için
kubectl exec -it {pod_adı} -- /bin/bash
  • Herhangi bir pod'u olmayan Replica Set'leri silmek için
kubectl delete replicaset $(kubectl get replicaset -o jsonpath='{ .items[?(@.spec.replicas==0)].metadata.name }')
  • Kubectl Cheat Sheet'de temel bazı komutları bulmak mümkün

  • Docker imajlarını oluşturup ACR'e Push etmek için

az acr build --registry k8simagesregistery --image app:v1 .

!!!BONUS!!!😀 !!!BONUS!!!😀

Yeni bir şeyler öğrenmek çok zevkli. Bu yüzden k8s'i daha iyi anlamak, tecrübe edebilmek için farklı bir platform ile tanışmak da istedim. AWS üzerinde Kubernetes nasıl konumlandırılmış buna bakmaya çalıştım. Bundan dolayı bu BONUS ortaya çıktı.

Amazon Elastic Kubernetes Service(AWS EKS) ile yine benzer şekilde terraform ile bir cluster nasıl oluşturulur, k8s dinamiklikleri neler daha iyi öğrenmek için de fırsat. Amazon Elastic Kubernetes Service(AWS EKS) ile ilgili bilgiler için buraya...

  • infrastructure/aws klasörü altında yine benzer terraform yaklaşımları ile ilerleyebiliyoruz.

  • Benzer şekilde AWS EKS'de oluşturulmuş bir k8s cluster'ını yönetebilmek için yine kubectl'den faydalanabiliyoruz

  • AWS CLI kullanarak komut satırından EKS cluster'ını yönetebiliyoruz.

    • AWS CLI'ı kurmak için
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    unzip awscliv2.zip
    sudo ./aws/install
    
    • AWS CLI'ın konfigürasyonu için; AWS hesabı ile komut satırı komutlarının çalışmasını ilişkilendiriyoruz
    aws configure
    
    curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/aws-iam-authenticator
    chmod +x ./aws-iam-authenticator
    mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
    echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc
    
    • kubectl ile AWS EKS cluster'ını ilişkilendiriyoruz ki, kubectl komutlarımız EKS cluster'ı için çalışsın
    aws sts get-caller-identity
    aws eks --region {region} update-kubeconfig --name {cluster_name}
    

azure-k8s-service's People

Contributors

ardacetinkaya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.