-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dec0b24
commit b226364
Showing
4 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: azure-vote-back1 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: azure-vote-back1 | ||
template: | ||
metadata: | ||
labels: | ||
app: azure-vote-back1 | ||
spec: | ||
containers: | ||
- name: azure-vote-back1 | ||
image: redis | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
limits: | ||
cpu: 250m | ||
memory: 256Mi | ||
ports: | ||
- containerPort: 6379 | ||
name: redis | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: azure-vote-back1 | ||
spec: | ||
ports: | ||
- port: 6379 | ||
selector: | ||
app: azure-vote-back1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: azure-vote-front1 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: azure-vote-front1 | ||
template: | ||
metadata: | ||
labels: | ||
app: azure-vote-front1 | ||
spec: | ||
containers: | ||
- name: azure-vote-front1 | ||
image: microsoft/azure-vote-front:v1 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
limits: | ||
cpu: 250m | ||
memory: 256Mi | ||
ports: | ||
- containerPort: 80 | ||
env: | ||
- name: REDIS | ||
value: "azure-vote-back1" | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: azure-vote-front1 | ||
annotations: | ||
service.beta.kubernetes.io/azure-load-balancer-tcp-idle-timeout: "4" | ||
# service.beta.kubernetes.io/azure-load-balancer-internal: "true" | ||
# service.beta.kubernetes.io/azure-load-balancer-internal-subnet: "svc" | ||
spec: | ||
type: LoadBalancer | ||
ports: | ||
- port: 80 | ||
selector: | ||
app: azure-vote-front1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
az aks get-credentials --resource-group RG-AKS --name aks-ussc-sav | ||
az aks isntall-cli | ||
|
||
kubectl cluster-info | ||
kubectl get nodes | ||
|
||
kubectl apply -f azure-vote.yaml | ||
|
||
kubectl get pods -o wide | ||
kubectl get service | ||
|
||
#note the endpoints for the frontend points to the IP of the frontend pod IP | ||
kubectl get endpoints azure-vote-front1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using namespace System.Net | ||
|
||
# Input bindings are passed in via param block. | ||
param($Request, $TriggerMetadata) | ||
|
||
#Import Az.ResourceGraph (not required as loaded via requirements.psd1) | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host "PowerShell HTTP trigger function processed a request." | ||
|
||
#Set initial status | ||
$statusGood = $true | ||
|
||
# Interact with query parameters or the body of the request. | ||
$ostype = $Request.Query.OSType | ||
|
||
if (-not $ostype) { | ||
$ostype = $Request.Body.OSType | ||
} | ||
|
||
#Find the VM resource via the computername | ||
$GraphSearchQuery = "Resources | ||
| where type =~ 'Microsoft.Compute/virtualMachines' | ||
| where properties.storageProfile.osDisk.osType =~ '$ostype' | ||
| join kind=inner (ResourceContainers | where type=='microsoft.resources/subscriptions'| project SubName=name, subscriptionId) on subscriptionId | ||
| project name, OSType = properties.storageProfile.osDisk.osType,CompName = properties.osProfile.computerName, RGName = resourceGroup,SubID = subscriptionId, SubName | ||
" | ||
$VMresources = Search-AzGraph -Query $GraphSearchQuery | ||
|
||
if($VMresources -eq $null) | ||
{ | ||
$statusGood = $false | ||
$body = "Could not find a matching VM resource" | ||
} | ||
else | ||
{ | ||
$body = $VMresources | ||
} | ||
|
||
if(!$statusGood) { | ||
$status = [HttpStatusCode]::BadRequest | ||
} | ||
else { | ||
$status = [HttpStatusCode]::OK | ||
} | ||
|
||
$BodyJSON = ConvertTo-Json($body) | ||
|
||
|
||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = $status | ||
Body = $BodyJSON | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$URIValue = "https://savtechosexecute.azurewebsites.net/api/VMList?code===" | ||
$BodyObject = [PSCustomObject]@{"ostype"="Linux"} | ||
$BodyJSON = ConvertTo-Json($BodyObject) | ||
$response = Invoke-WebRequest -Uri $URIValue -Method POST -Body $BodyJSON -ContentType 'application/json' | ||
$response.content |