Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
157 changes: 82 additions & 75 deletions labs/outer-loop-aks-azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,115 +17,124 @@ git branch --show-current

## Login to Azure

- Login to Azure using `az login --use-device-code`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use bulleted lists throughout the document. Changing to normal text will remove consistency unless we change every doc which isn't feasible.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I did go through all the different labs and made them sentence-based instead of bullet lists in #24 but since I'm breaking these up into smaller PRs, it may seem more scattered. I'm still trying to get a few more smaller PRs in over the next few days.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindlessroman - Apologies for the delay here. We discussed as a team and we'd prefer to keep the style/formatting as-is, since it is what we have been used to conforming to in all of our repo/docs. If you get a chance, please revert the style/formatting changes but keep any wording/script improvements.

Thank you for contributing here!

> Use `az login --use-device-code --tenant <tenant>` to specify a different tenant
- If you have more than one Azure subscription, select the correct subscription
Login to Azure using `az login --use-device-code`.

```bash
Use `az login --use-device-code --tenant <tenant>` to specify a different tenant if you have access
to more than one tenant.

# verify your account
az account show
If you have more than one Azure subscription, select the correct subscription:

# list your Azure accounts
az account list -o table
```bash

# set your Azure subscription
az account set -s mySubNameOrId
# verify your account
az account show

# verify your account
az account show
# list your Azure accounts
az account list -o table

```
# set your Azure subscription
az account set -s mySubNameOrId

- Validate user role on subscription
> Make sure your RoleDefinitionName is `Contributor` or `Owner` to create resources in this lab succssfully
# verify your account
az account show

```bash
```

# get az user name and validate your role assignment
principal_name=$(az account show --query "user.name" --output tsv | sed -r 's/[@]+/_/g')
az role assignment list --query "[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope} | [? contains(principalName,'$principal_name')]" -o table
Validate user role on the subscription. Make sure your RoleDefinitionName is `Contributor` or `Owner`
to create resources in this lab successfully.

```
```bash

## Create Arc enabled AKS Cluster
# get az user name and validate your role assignment
principal_name=$(az account show --query "user.name" --output tsv | sed -r 's/[@]+/_/g')
az role assignment list --query "[].{principalName:principalName, roleDefinitionName:roleDefinitionName, scope:scope} | [? contains(principalName,'$principal_name')]" -o table

### Create AKS Cluster
```

> This AKS setup is insecure and intended for learning, dev and test only. For secure or production clusters, please refer [AKS Secure Baseline](https://github.com/mspnp/aks-baseline)
## Create Arc-enabled AKS Cluster

```bash
### Create AKS Cluster

# set MY_AKS_CLUSTER
export MY_AKS_CLUSTER=central-tx-atx-$MY_BRANCH-aks
> ⛔️ This AKS setup is **insecure** and intended for learning, dev and test only. For secure
> or production clusters, please refer [AKS Secure Baseline](https://github.com/mspnp/aks-baseline).

# set MY_RG
export MY_RG=$MY_BRANCH-rg
```bash

```
# set MY_AKS_CLUSTER
export MY_AKS_CLUSTER=central-tx-atx-$MY_BRANCH-aks

```bash
# set MY_RG
export MY_RG=$MY_BRANCH-rg

# create resource group
az group create --name $MY_RG --location eastus
# create resource group
az group create --name $MY_RG --location eastus

# create AKS cluster
# this may take 3-5 mins
az aks create -g $MY_RG -n $MY_AKS_CLUSTER --enable-managed-identity --node-count 1 --generate-ssh-keys
# create AKS cluster
# this may take 3-5 mins
az aks create -g $MY_RG -n $MY_AKS_CLUSTER \
--enable-managed-identity --node-count 1 \
--generate-ssh-keys

```
```

### Arc enable the AKS Cluster

```bash
```bash

# install the connectedk8s Azure CLI extension
az extension add --name connectedk8s
# install the connectedk8s Azure CLI extension
az extension add --name connectedk8s

# get aks creds
az aks get-credentials --resource-group $MY_RG --name $MY_AKS_CLUSTER
# get aks creds
az aks get-credentials --resource-group $MY_RG --name $MY_AKS_CLUSTER

# arc enable
# this may take 2-3 mins
az connectedk8s connect --name $MY_AKS_CLUSTER --resource-group $MY_RG --location eastus
# arc enable
# this may take 2-3 mins
az connectedk8s connect --name $MY_AKS_CLUSTER \
--resource-group $MY_RG \
--location eastus

```
```

## Set up for GitOps

### Flt setup
### `flt` setup

```bash

```bash
# create the cluster metadata
flt create --gitops-only -c $MY_AKS_CLUSTER

# create the cluster metadata
flt create --gitops-only -c $MY_AKS_CLUSTER
```

```
This will create the cluster metadata for GitOps. You will have to wait for the CI/CD steps to
complete.

- This will create the cluster metadata for GitOps
- Wait for ci-cd to complete
- run `git pull`
- You should see the yaml files created in the `clusters` directory
Run `git pull` and you should see the yaml files created in the `clusters` directory!

### Create flux secret

```bash
```bash

# create secret for GitOps
kubectl apply -f "clusters/$MY_AKS_CLUSTER/flux-system/namespace.yaml"

# create secret for GitOps
kubectl apply -f "clusters/$MY_AKS_CLUSTER/flux-system/namespace.yaml"
flux create secret git flux-system -n flux-system --url "$PIB_FULL_REPO" -u gitops -p "$PIB_PAT"
flux create secret git flux-system \
-n flux-system \
--url "$PIB_FULL_REPO" \
-u gitops -p "$PIB_PAT"

```
```

## Create GitOps configuration with Arc

- All of the values you need for Arc setup are displayed via `flt env` and starts with PIB_*
All of the values you need for Arc setup are displayed via `flt env` and start with `PIB_*`.

- From the Azure Arc Portal
- Select `Kubernetes Clusters` in left nav
- Select the cluster
- Select `GitOps` in the left nav
- Click `Create`
- Go to the Azure Arc Portal.
- Select `Kubernetes Clusters` in left navigation.
- Select the cluster.
- Select `GitOps` in the left navigation.
- Click `Create`.
- The recommended settings are:
- Basics:
- Configuration Name: `gitops`
- Namespace: `flux-system`
Expand All @@ -134,7 +143,7 @@ git branch --show-current
- Source kind: `Git Repository`
- Repository URL: `https://github.com/kubernetes101/pib-dev`
- Reference type: `Branch`
- Branch: value of MY_BRANCH
- Branch: value of `MY_BRANCH`
- Repository Type:`Private`
- Authentication source: `Provide Authentication information here`
- HTTPS User: `gitops`
Expand All @@ -143,23 +152,21 @@ git branch --show-current
- Sync interval: 1 minute
- Sync timeout: 3 minutes
- Kustomization
- Instance name: flux-system
- Path: ./clusters/{{cluster-name}}/flux-system
- Instance name: `flux-system`
- Path: `./clusters/{{cluster-name}}/flux-system`
- Sync interval: 1 minute
- Sync timeout: 3 minutes
- Retry interval: 1 minute
- Prune: checked
- Force: checked
- Depends on: leave blank
- Wait for gitops configuration to be created
- Select `Configuration objects` from the left nav of `GitOps` config
- Wait for `gitops-flux-system` to be created
- Wait for it to be `Compliant`
- Wait for GitOps configuration to be created.
- Select `Configuration objects` from the left navigation of the `GitOps` configuration.
- Wait for `gitops-flux-system` to be created, and then for it to be "Compliant."

## Check in Arc Portal

- Use the Arc Portal to check GitOps setup
- Check cluster namespaces and workloads
Use the Arc Portal to check GitOps setup. Check on the cluster namespaces and workloads.

## Deploy sample app

Expand All @@ -186,7 +193,7 @@ git pull

## Cleanup

- Once you're finished with the workshop and experimenting, delete your cluster and Azure resources
Once you're finished with the workshop and experimenting, delete your cluster and Azure resources:

```bash

Expand Down
Loading