Öğretici: Azure Kubernetes hizmeti (AKS) için uygulama hazırlamaTutorial: Prepare an application for Azure Kubernetes Service (AKS)
Bu yedi parçalık öğreticinin ilk bölümünde, bir çoklu kapsayıcı uygulaması Kubernetes’te kullanılmak üzere hazırlanmaktadır.In this tutorial, part one of seven, a multi-container application is prepared for use in Kubernetes. Uygulamayı yerel ortamda derlemek ve test etmek için Docker Compose gibi var olan geliştirme araçları kullanılmaktadır.Existing development tools such as Docker Compose are used to locally build and test an application. Aşağıdakileri nasıl yapacağınızı öğrenirsiniz:You learn how to:
- Örnek bir uygulama kaynağını GitHub’dan kopyalamaClone a sample application source from GitHub
- Örnek uygulama kaynağından kapsayıcı görüntüsü oluşturmaCreate a container image from the sample application source
- Çok kapsayıcılı uygulamayı yerel bir Docker ortamında test etmeTest the multi-container application in a local Docker environment
Tamamlandıktan sonra, aşağıdaki uygulama yerel geliştirme ortamınızda çalışacaktır:Once completed, the following application runs in your local development environment:
Ek öğreticilerde, kapsayıcı görüntüsü bir Azure Container Registry yüklenir ve ardından bir AKS kümesine dağıtılır.In additional tutorials, the container image is uploaded to an Azure Container Registry, and then deployed into an AKS cluster.
Başlamadan önceBefore you begin
Bu öğreticide kapsayıcılar, kapsayıcı görüntüleri ve docker
komutları gibi temel Docker kavramları hakkında bilgi sahibi olduğunuz varsayılmıştır.This tutorial assumes a basic understanding of core Docker concepts such as containers, container images, and docker
commands. Kapsayıcı temelleri hakkında bilgi için bkz. Docker ile çalışmaya başlama.For a primer on container basics, see Get started with Docker.
Bu öğreticiyi tamamlamak için Linux kapsayıcılarını çalıştıran yerel bir Docker geliştirme ortamı gerekir.To complete this tutorial, you need a local Docker development environment running Linux containers. Docker, bir Mac, Windowsveya Linux sisteminde Docker 'ı yapılandıran paketler sağlar.Docker provides packages that configure Docker on a Mac, Windows, or Linux system.
Azure Cloud Shell, bu öğreticilerdeki her adımı tamamlamak için gerekli olan Docker bileşenlerini içermez.Azure Cloud Shell does not include the Docker components required to complete every step in these tutorials. Bu yüzden, eksiksiz bir Docker geliştirme ortamı kullanmanızı öneririz.Therefore, we recommend using a full Docker development environment.
Uygulama kodunu almaGet application code
Bu öğreticide kullanılan örnek uygulama, temel oylama uygulamasıdır.The sample application used in this tutorial is a basic voting app. Bu uygulama, ön uç bileşen ile arka uç Redis örneğinden oluşur.The application consists of a front-end web component and a back-end Redis instance. Web bileşeni, özel kapsayıcı görüntüsüne paketlenmiştir.The web component is packaged into a custom container image. Redis örneği, Docker Hub’dan alınan değiştirilmemiş bir görüntü kullanır.The Redis instance uses an unmodified image from Docker Hub.
Örnek uygulamayı geliştirme ortamınıza kopyalamak için git komutunu kullanın:Use git to clone the sample application to your development environment:
git clone https://github.com/Azure-Samples/azure-voting-app-redis.git
Kopyalanmış dizine geçin.Change into the cloned directory.
cd azure-voting-app-redis
Dizinin içinde uygulama kaynak kodu, önceden oluşturulmuş Docker Compose dosyası ve Kubernetes bildirim dosyası bulunur.Inside the directory is the application source code, a pre-created Docker compose file, and a Kubernetes manifest file. Bu dosyalar öğretici kümesi boyunca kullanılır.These files are used throughout the tutorial set.
Kapsayıcı görüntüleri oluşturmaCreate container images
Docker Compose , kapsayıcı görüntüleri oluşturmayı ve çok Kapsayıcılı uygulamaların dağıtımını otomatikleştirmek için kullanılabilir.Docker Compose can be used to automate building container images and the deployment of multi-container applications.
Kapsayıcı görüntüsünü oluşturmak için örnek docker-compose.yaml
dosyasını çalıştırın, Redis görüntüsünü indirin ve uygulamayı başlatın:Use the sample docker-compose.yaml
file to create the container image, download the Redis image, and start the application:
docker-compose up -d
Tamamlandığında, oluşturulan görüntüleri görmek için docker images komutunu kullanın.When completed, use the docker images command to see the created images. Üç görüntü indirilir veya oluşturulur.Three images have been downloaded or created. azure-vote-front görüntüsü uygulamayı içerir ve temel olarak nginx-flask
görüntüsünü kullanır.The azure-vote-front image contains the front-end application and uses the nginx-flask
image as a base. redis
görüntüsü bir Redis örneği başlatmak için kullanılır.The redis
image is used to start a Redis instance.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
azure-vote-front latest 9cc914e25834 40 seconds ago 694MB
redis latest a1b99da73d05 7 days ago 106MB
tiangolo/uwsgi-nginx-flask flask 788ca94b2313 9 months ago 694MB
Çalışan kapsayıcıları görmek için Docker PS komutunu çalıştırın:Run the docker ps command to see the running containers:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82411933e8f9 azure-vote-front "/usr/bin/supervisord" 57 seconds ago Up 30 seconds 443/tcp, 0.0.0.0:8080->80/tcp azure-vote-front
b68fed4b66b6 redis "docker-entrypoint..." 57 seconds ago Up 30 seconds 0.0.0.0:6379->6379/tcp azure-vote-back
Uygulamayı yerel olarak test etmeTest application locally
Çalışan uygulamayı görmek için yerel web tarayıcısına http://localhost:8080
yazın.To see the running application, enter http://localhost:8080
in a local web browser. Örnek uygulama aşağıdaki örnekte gösterilen şekilde yüklenir:The sample application loads, as shown in the following example:
Kaynakları temizlemeClean up resources
Artık uygulama işlevselliği doğrulandığından, çalışan kapsayıcılar durdurulup kaldırılabilir.Now that the application's functionality has been validated, the running containers can be stopped and removed. Kapsayıcı görüntülerini silmeyin. Bir sonraki öğreticide azure-vote-front görüntüsü bir Azure Container Registry örneğine yüklenecektir.Do not delete the container images - in the next tutorial, the azure-vote-front image is uploaded to an Azure Container Registry instance.
Docker-Compose aşağı komutuyla kapsayıcı örneklerini ve kaynakları durdurun ve kaldırın:Stop and remove the container instances and resources with the docker-compose down command:
docker-compose down
Yerel uygulama kaldırıldığında, sonraki öğreticide kullanılmak üzere Azure oy uygulamasını, Azure-oyönünüIçeren bir Docker görüntüsüne sahip olursunuz.When the local application has been removed, you have a Docker image that contains the Azure Vote application, azure-vote-front, for use with the next tutorial.
Sonraki adımlarNext steps
Bu öğreticide bir uygulama test edildi ve bu uygulamaya yönelik kapsayıcı görüntüleri oluşturuldu.In this tutorial, an application was tested and container images created for the application. Şunları öğrendiniz:You learned how to:
- Örnek bir uygulama kaynağını GitHub’dan kopyalamaClone a sample application source from GitHub
- Örnek uygulama kaynağından kapsayıcı görüntüsü oluşturmaCreate a container image from the sample application source
- Çok kapsayıcılı uygulamayı yerel bir Docker ortamında test etmeTest the multi-container application in a local Docker environment
Kapsayıcı görüntülerini Azure Container Registry’de depolamayı öğrenmek için sonraki öğreticiye geçin.Advance to the next tutorial to learn how to store container images in Azure Container Registry.
Geri Bildirim
Geri bildirim yükleniyor...