Since you opened a new command prompt in the previous step, you'll need to return to the directory you created your service in.
Since you opened a new terminal in the previous step, you'll need to return to the directory you created your service in.
The AKS tools use a
.yaml file to define how to deploy your container.
Create a file called
deploy.yaml with this command:
fsutil file createnew deploy.yaml 0
You can then open it in your favorite text editor.
You can then open it in your favorite text editor manually or with this command:
Replace the content of the
deploy.yaml to the following in the text editor, making sure to replace [YOUR DOCKER ID] with your actual Docker ID.
--- apiVersion: apps/v1 kind: Deployment metadata: name: mymicroservice spec: replicas: 1 template: metadata: labels: app: mymicroservice spec: containers: - name: mymicroservice image: [YOUR DOCKER ID]/mymicroservice:latest ports: - containerPort: 80 env: - name: ASPNETCORE_URLS value: http://*:80 selector: matchLabels: app: mymicroservice --- apiVersion: v1 kind: Service metadata: name: mymicroservice spec: type: LoadBalancer ports: - port: 80 selector: app: mymicroservice
Run the following command to deploy your microservice based on the settings in
kubectl apply -f deploy.yaml
Run the following command to see the details of your deployed service:
kubectl get service mymicroservice --watch
Among other things, the previous command will show the external IP address that your service is available on (EXTERNAL-IP).
Using the external IP address, open a new browser window and navigate to http://[YOUR EXTERNAL IP ADDRESS]/WeatherForecast
If the EXTERNAL-IP is marked as
<pending>, a new line will automatically appear once the external IP has been allocated.
Press CTRL+C on your command prompt to end the
kubectl get service command.
Press CTRL+C on your terminal to end the
kubectl get service command
Congratulations! You've deployed a microservice to Azure.