Skip to content

Upgrade to Kubernetes 1.16.x #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e14fe2d
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 27, 2020
d704913
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 27, 2020
c86fd76
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 28, 2020
292d7cb
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 28, 2020
2b17e31
AZURE-REGISTRY-USERNAME and AZURE-REGISTRY-PASSWORD
joedayz Aug 29, 2020
defe13b
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 29, 2020
7241e90
Update azure-pipelines.yml for Azure Pipelines
joedayz Aug 29, 2020
ff4c61e
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
d45b7c5
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
27974da
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
32270d9
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
0b117ce
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
2e1a53e
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
6a1367c
Upgrade to kubernetes 1.16.x
joedayz Aug 29, 2020
07a19f9
Add in Pipelines - Environment un Azure Kubernetes Resource
Aug 29, 2020
5621f82
applying effect to image
Aug 29, 2020
5a0ecfc
create kubernetes service connection
Aug 29, 2020
00ecb68
RabbitMQ Certified by Bitnami
joedayz Aug 29, 2020
54d8d1d
Update of rabbitmq information
joedayz Aug 29, 2020
8557568
Configure Key Vault and secrets
Aug 29, 2020
e3d53d4
Merge branch 'master' of https://github.com/joedayz/java-on-aks
Aug 29, 2020
58c9d1b
get token with az acr login with --expose-token
Aug 29, 2020
7632497
get client id from service principal
Aug 29, 2020
0bd116b
azure key vault is kv-joedayz-demo
joedayz Sep 28, 2020
3492ec5
kv-joedayz-demo
joedayz Sep 28, 2020
81c85de
test
joedayz Sep 28, 2020
2c21504
Update azure-pipelines.yml
joedayz Sep 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,37 @@ There are some additional prerequisites for this automation:
- [GitHub Account](https://github.com/)
- [Azure DevOps Organization](https://docs.microsoft.com/en-us/azure/devops/pipelines/get-started/pipelines-sign-up?view=azure-devops)
- [Environment with AKS resource](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/environments-kubernetes?view=azure-devops#azure-kubernetes-service) which creates a service account in the chosen cluster and namespace, which will be used by Azure DevOps account to deploy to AKS

![](./media/azure-resource-environment.jpg)

- [Azure service connection using service principal](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure?view=azure-devops#create-an-azure-resource-manager-service-connection-with-an-existing-service-principal) to establish authentication between Azure & Azure DevOps services

![](./media/kubernetes-service-connection.jpg)

> [!Important]
> To simplify the service connection, use the same email address for Azure DevOps as you use for Azure.
- Create an Azure KeyVault and upload secrets. Ensure the service principal used in the service connection above has GET, LIST [permissions](https://docs.microsoft.com/en-us/cli/azure/keyvault?view=azure-cli-latest#az-keyvault-set-policy) on the vault. Use below command for that:
- Create an Azure KeyVault and upload secrets.

![](./media/kv-java-demo.jpg)

```
AZURE-REGISTRY-USERNAME=00000000-0000-0000-0000-000000000000
AZURE-REGISTRY-PASSWORD=<Token obtained according to instrucciones in it url: https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication>
```

Ensure the service principal used in the service connection above has GET, LIST [permissions](https://docs.microsoft.com/en-us/cli/azure/keyvault?view=azure-cli-latest#az-keyvault-set-policy) on the vault. Use below command for that:

```
$KV_NAME = kv_java_demo
<clientId from the Azure SPN JSON> is obtained from the Azure Resource Manager created earlier.
```

![](./media/azure-resource-manager-get-principal.jpg)

Next, you must to copy the cliente Id.

![](./media/client-id-service-principal.jpg)

```
az keyvault set-policy -n $KV_NAME --secret-permissions get list --spn <clientId from the Azure SPN JSON>
```
Expand Down
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
- repo: self

variables:
CONTAINER_REGISTRY: 'javademosregistry'
CONTAINER_REGISTRY: 'acr061174'
CONFIG_PORT: '8888'
REGISTRY_PORT: '8761'
GATEWAY_PORT: '4000'
Expand All @@ -33,8 +33,8 @@ stages:
- task: AzureKeyVault@1
displayName: Fetch secrets from Azure Key vault
inputs:
azureSubscription: 'Java Demos 2'
KeyVaultName: 'piggymetrics'
azureSubscription: 'arm-workshop-demo'
KeyVaultName: 'kv-joedayz-demo'
SecretsFilter: '*'

- task: Bash@3
Expand Down Expand Up @@ -91,16 +91,16 @@ stages:
displayName: Deploy to AKS
pool:
vmImage: $(vmImageName)
environment: 'Piggymetrics.piggymetrics-azp'
environment: 'Piggymetrics.default'
strategy:
runOnce:
deploy:
steps:
- task: AzureKeyVault@1
displayName: Fetch secrets from Azure Key vault
inputs:
azureSubscription: 'Java Demos 2'
KeyVaultName: 'piggymetrics'
azureSubscription: 'arm-workshop-demo'
KeyVaultName: 'kv-joedayz-demo'
SecretsFilter: '*'

- task: replacetokens@3
Expand Down
13 changes: 9 additions & 4 deletions docs/create-mongodb-and-rabbitmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ Cut and paste the primary connection string as `MONGODB_URI` in `setup-env-varia

## Create RabbitMQ

Create an instance of Bitnami RabbitMQ Stack For Microsoft Azure, go to
Create an instance of RabbitMQ Certified by Bitnami For Microsoft Azure, go to
[https://portal.azure.com/#blade/Microsoft_Azure_Marketplace/MarketplaceOffersBlade/selectedMenuItemId/home/searchQuery/rabbitmq](https://portal.azure.com/#blade/Microsoft_Azure_Marketplace/MarketplaceOffersBlade/selectedMenuItemId/home/searchQuery/rabbitmq)
and start:

![](../media/create-rabbitmq-on-azure-0.jpg)


Fill in the form, use the same value as `RABBITMQ_RESOURCE_GROUP`,
`RABBITMQ_VM_NAME` and `RABBITMQ_VM_ADMIN_USERNAME`, and choose SSH. Select 'Standard DS3 v2' as
the size:
Expand All @@ -91,7 +92,9 @@ Accept defaults:
Accept defaults:
![](../media/create-rabbitmq-on-azure-2.jpg)

Accept defaults in all subsequent screens, and proceed to create:
Accept defaults in all subsequent screens (Don't forget to download the .pem file), and proceed to create:


![](../media/create-rabbitmq-on-azure-3.jpg)

![](../media/create-rabbitmq-on-azure-4.jpg)
Expand All @@ -113,7 +116,9 @@ and set the `RABBITMQ_HOST` environment variable in
# First, export the environment variables
source .scripts/setup-env-variables-azure.sh
# Open an SSH connection
ssh selvasingh@${RABBITMQ_HOST}
chmod 400 rabbitmqxxxx.pem

ssh -i rabbitmqxxxx.pem selvasingh@${RABBITMQ_HOST} (selvassingh is your rabbitmq admin)
```

You can adjust RabbitMQ to connect with clients from a different machine:
Expand Down Expand Up @@ -201,4 +206,4 @@ export RABBITMQ_PASSWORD=INSERT-your-rabbitmq-password

```

Go back to [How to use AKS end-to-end for Java apps?](https://github.com/azure-samples/java-on-aks)
Go back to [How to use AKS end-to-end for Java apps?](https://github.com/azure-samples/java-on-aks)
35 changes: 19 additions & 16 deletions kubernetes/1-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ metadata:
spec:
type: LoadBalancer
ports:
- name: http
port: 8888
targetPort: 8888
- name: http
port: 8888
targetPort: 8888
selector:
project: piggymetrics
tier: middleware
app: config
status:
loadBalancer: {}
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
Expand All @@ -32,6 +32,9 @@ spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app: config
template:
metadata:
labels:
Expand All @@ -40,16 +43,16 @@ spec:
app: config
spec:
containers:
- env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: ${CONTAINER_REGISTRY}.azurecr.io/piggymetrics-config:${IMAGE_TAG}
name: config
ports:
- containerPort: 8888
resources: {}
- env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: acr061174.azurecr.io/piggymetrics-config:dev
name: config
ports:
- containerPort: 8888
resources: {}
restartPolicy: Always
status: {}
status: {}
35 changes: 19 additions & 16 deletions kubernetes/2-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ metadata:
spec:
type: LoadBalancer
ports:
- name: http
port: 8761
targetPort: 8761
- name: http
port: 8761
targetPort: 8761
selector:
project: piggymetrics
tier: middleware
app: registry
status:
loadBalancer: {}
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
Expand All @@ -32,6 +32,9 @@ spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app: registry
template:
metadata:
labels:
Expand All @@ -40,16 +43,16 @@ spec:
app: registry
spec:
containers:
- env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: ${CONTAINER_REGISTRY}.azurecr.io/piggymetrics-registry:${IMAGE_TAG}
name: registry
ports:
- containerPort: 8761
resources: {}
- env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: ${CONTAINER_REGISTRY}.azurecr.io/piggymetrics-registry:${IMAGE_TAG}
name: registry
ports:
- containerPort: 8761
resources: {}
restartPolicy: Always
status: {}
status: {}
33 changes: 18 additions & 15 deletions kubernetes/3-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ metadata:
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 4000
- name: http
port: 80
targetPort: 4000
selector:
project: piggymetrics
tier: frontend
app: gateway
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway
Expand All @@ -30,6 +30,9 @@ spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app: gateway
template:
metadata:
creationTimestamp: null
Expand All @@ -39,14 +42,14 @@ spec:
app: gateway
spec:
containers:
- name: gateway
env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: ${CONTAINER_REGISTRY}.azurecr.io/piggymetrics-gateway:${IMAGE_TAG}
ports:
- containerPort: 4000
restartPolicy: Always
- name: gateway
env:
- name: CONFIG_SERVICE_PASSWORD
valueFrom:
secretKeyRef:
name: piggymetrics
key: config_service_password
image: ${CONTAINER_REGISTRY}.azurecr.io/piggymetrics-gateway:${IMAGE_TAG}
ports:
- containerPort: 4000
restartPolicy: Always
Loading