Skip to content
Merged
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
62 changes: 38 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ The general directory structure is:
│ ├── windows/ - scripts to build the Docker image for Windows Agent
│ │ ├── dockerbuild - script to build the code and docker imag, and publish docker image
│ │ ├── acrworkflows/ - acr work flows for the Windows Agent container image
│ │ ├── baseimage/ - windowsservercore base image for the windows agent container
│ │ ├── DockerFile - DockerFile for Windows Agent Container Image
│ │ ├── main.ps1 - Windows Agent container entry point
│ │ ├── setup.ps1 - setup file for Windows Agent Container Image
Expand Down Expand Up @@ -140,7 +139,7 @@ bash ~/Docker-Provider/scripts/build/linux/install-build-pre-requisites.sh

### Build Docker Provider Shell Bundle and Docker Image and Publish Docker Image

> Note: If you are using WSL2, ensure Docker for windows running Linux containers mode to build Linux agent image successfully
> Note: If you are using WSL2, ensure `Docker for windows` running with Linux containers mode on your windows machine to build Linux agent image successfully

```
cd ~/Docker-Provider/kubernetes/linux/dockerbuild
Expand All @@ -167,9 +166,23 @@ docker push <repo>/<imagename>:<imagetag>
```
## Windows Agent

To build the windows agent, you will have to build .NET and Go code, and docker image for windows agent.
Docker image for windows agent can only build on Windows machine with `Docker for windows` with Windows containers mode but the .NET code and Go code can be built either on Windows or Linux or WSL2.

### Install Pre-requisites

If you are planning to build the .net and go code for windows agent on Linux machine and you have already have Docker for Windows on Windows machine, then you may skip this.
Install pre-requisites based on OS platform you will be using to build the windows agent code

#### Option 1 - Using Windows Machine to Build the Windows agent

```
powershell # launch powershell with elevated admin on your windows machine
Set-ExecutionPolicy -ExecutionPolicy bypass # set the execution policy
cd %userprofile%\Docker-Provider\scripts\build\windows # based on your repo path
.\install-build-pre-requisites.ps1 #
```

#### Option 2 - Using WSL2 to Build the Windows agent

```
powershell # launch powershell with elevated admin on your windows machine
Expand All @@ -178,20 +191,36 @@ net use z: \\wsl$\Ubuntu-16.04 # map the network drive of the ubuntu app to wind
cd z:\home\sshadmin\Docker-Provider\scripts\build\windows # based on your repo path
.\install-build-pre-requisites.ps1 #
```
#### Build Certificate Generator Source code and Out OMS Go plugin code

> Note: .net and go code for windows agent can built on Ubuntu

### Build Windows Agent code and Docker Image

> Note: format of the windows agent imagetag will be `win-ci<release><MMDDYYYY>`. possible values for release are test, dev, preview, dogfood, prod etc.

#### Option 1 - Using Windows Machine to Build the Windows agent

Execute below instructions on elevated command prompt to build windows agent code and docker image, publishing the image to acr or docker hub

```
cd %userprofile%\Docker-Provider\kubernetes\windows\dockerbuild # based on your repo path
docker login # if you want to publish the image to acr then login to acr via `docker login <acr-name>`
powershell -ExecutionPolicy bypass # switch to powershell if you are not on powershell already
.\build-and-publish-docker-image.ps1 -image <repo>/<imagename>:<imagetag> # trigger build code and image and publish docker hub or acr
```

#### Option 2 - Using WSL2 to Build the Windows agent

##### On WSL2, Build Certificate Generator Source code and Out OMS Go plugin code

```
cd ~/Docker-Provider/build/windows # based on your repo path on ubuntu or WSL2
cd ~/Docker-Provider/build/windows # based on your repo path on WSL2 Ubuntu app
pwsh #switch to powershell
.\Makefile.ps1 # trigger build and publish of .net and go code
```
> Note: format of the imagetag will be `win-ci<release><MMDDYYYY>`. possible values for release are test, dev, preview, dogfood, prod etc.

#### Build and Push Docker Image
#### On Windows machine, build and Push Docker Image

> Note: windows container can only built on windows hence you will have to execute below commands on windows via accessing network share or copying published bits omsagentwindows under kubernetes directory on to windows machine
> Note: Docker image for windows container can only built on windows hence you will have to execute below commands on windows via accessing network share or copying published bits omsagentwindows under kubernetes directory on to windows machine

```
net use z: \\wsl$\Ubuntu-16.04 # map the network drive of the ubuntu app to windows
Expand All @@ -200,21 +229,6 @@ docker build -t <repo>/<imagename>:<imagetag> --build-arg IMAGE_TAG=<imagetag> .
docker push <repo>/<imagename>:<imagetag>
```

### Build Cert generator, Out OMS Plugin and Docker Image and Publish Docker Image

If you have code cloned on to windows, you can built everything for windows agent on windows machine via below instructions

```
# install pre-requisites if you havent installed already
cd %userprofile%\Docker-Provider\kubernetes\windows # based on your repo path
.\install-build-pre-requisites.ps1

cd %userprofile%\Docker-Provider\kubernetes\windows\dockerbuild # based on your repo path
docker login # if you want to publish the image to acr then login to acr via `docker login <acr-name>`
powershell -ExecutionPolicy bypass # switch to powershell if you are not on powershell already
.\build-and-publish-docker-image.ps1 -image <repo>/<imagename>:<imagetag> # trigger build code and image and publish docker hub or acr
```

# Azure DevOps Build Pipeline

Navigate to https://github-private.visualstudio.com/microsoft/_build?view=pipelines to see Linux and Windows Agent build pipelines. These pipelines are configured with CI triggers for ci_dev and ci_prod.
Expand Down
2 changes: 1 addition & 1 deletion charts/azuremonitor-containers/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ keywords:
- kubernetes
- kuberneteshealth
home: https://docs.microsoft.com/en-us/azure/monitoring/monitoring-container-health
icon: https://raw.githubusercontent.com/Microsoft/OMS-docker/ci_feature/img/azuremonitor-containers.svg
icon: https://raw.githubusercontent.com/microsoft/Docker-Provider/ci_prod/img/azuremonitor-containers.svg
sources:
- https://github.com/microsoft/Docker-Provider/tree/ci_prod
maintainers:
Expand Down
4 changes: 2 additions & 2 deletions charts/azuremonitor-containers/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

{{- end }}

{{- if and (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") }}
{{- if and (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") }}

##############################################################################
#### ERROR: You did not provide cluster name ####
##############################################################################

{{- end }}

{{- if or (eq .Values.omsagent.secret.key "<your_workspace_key>") (eq .Values.omsagent.secret.wsid "<your_workspace_id>") (and (eq .Values.omsagent.env.clusterName "<your_cluster_name>") (eq .Values.omsagent.env.clusterId "<your_cluster_id>"))}}
{{- if or (eq .Values.omsagent.secret.key "<your_workspace_key>") (eq .Values.omsagent.secret.wsid "<your_workspace_id>") (and (eq .Values.omsagent.env.clusterName "<your_cluster_name>") (eq .Values.omsagent.env.clusterId "<your_cluster_id>") (eq .Values.Azure.Cluster.ResourceId "<your_cluster_id>") )}}

This deployment will not complete. To proceed, run
helm upgrade {{ .Release.Name }} \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if contains "microsoft.kubernetes/connectedclusters" (.Values.omsagent.env.clusterId | lower) }}
{{- if or ( contains "microsoft.kubernetes/connectedclusters" (.Values.Azure.Cluster.ResourceId | lower) ) ( contains "microsoft.kubernetes/connectedclusters" (.Values.omsagent.env.clusterId | lower)) }}
apiVersion: clusterconfig.azure.com/v1beta1
kind: AzureClusterIdentityRequest
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ spec:
dockerProviderVersion: {{ .Values.omsagent.image.dockerProviderVersion }}
schema-versions: "v1"
spec:
nodeSelector:
beta.kubernetes.io/os: windows
{{- if .Values.omsagent.rbac }}
serviceAccountName: omsagent
{{- end }}
Expand All @@ -46,6 +48,13 @@ spec:
- name: AKS_REGION
value: {{ .Values.omsagent.env.clusterRegion | quote }}
{{- end }}
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
{{- end }}
{{- else }}
- name: ACS_RESOURCE_NAME
value: {{ .Values.omsagent.env.clusterName | quote }}
Expand Down Expand Up @@ -80,9 +89,6 @@ spec:
- C:\opt\omsagentwindows\scripts\cmd\livenessProbe.cmd
periodSeconds: 60
initialDelaySeconds: 180
{{- with .Values.omsagent.daemonsetwindows.affinity }}
affinity: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.omsagent.tolerations }}
tolerations: {{- toYaml . | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>"))}}
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") )}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -46,6 +46,13 @@ spec:
- name: AKS_REGION
value: {{ .Values.omsagent.env.clusterRegion | quote }}
{{- end }}
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
{{- end }}
{{- else }}
- name: ACS_RESOURCE_NAME
value: {{ .Values.omsagent.env.clusterName | quote }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>"))}}
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") )}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -47,6 +47,13 @@ spec:
- name: AKS_REGION
value: {{ .Values.omsagent.env.clusterRegion | quote }}
{{- end }}
{{- else if ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>" }}
- name: AKS_RESOURCE_ID
value: {{ .Values.Azure.Cluster.ResourceId | quote }}
{{- if ne .Values.Azure.Cluster.Region "<your_cluster_region>" }}
- name: AKS_REGION
value: {{ .Values.Azure.Cluster.Region | quote }}
{{- end }}
{{- else }}
- name: ACS_RESOURCE_NAME
value: {{ .Values.omsagent.env.clusterName | quote }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>"))}}
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") )}}
kind: ConfigMap
apiVersion: v1
data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>"))}}
{{- if and (ne .Values.omsagent.secret.key "<your_workspace_key>") (ne .Values.omsagent.secret.wsid "<your_workspace_id>") (or (ne .Values.omsagent.env.clusterName "<your_cluster_name>") (ne .Values.omsagent.env.clusterId "<your_cluster_id>") (ne .Values.Azure.Cluster.ResourceId "<your_cluster_id>") )}}
apiVersion: v1
kind: Secret
metadata:
Expand Down
18 changes: 6 additions & 12 deletions charts/azuremonitor-containers/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
# Declare variables to be passed into your templates.

## Microsoft OMS Agent image for kubernetes cluster monitoring
## ref: https://github.com/Microsoft/OMS-docker/tree/ci_feature_prod
## ref: https://github.com/microsoft/Docker-Provider/tree/ci_prod
## Values of ResourceId and Region under Azure->Cluster being populated by Azure Arc K8s RP during the installation of the extension
Azure:
Cluster:
Region: <your_cluster_region>
ResourceId: <your_cluster_id>
omsagent:
image:
repo: "mcr.microsoft.com/azuremonitor/containerinsights/ciprod"
Expand Down Expand Up @@ -81,17 +86,6 @@ omsagent:
operator: NotIn
values:
- master
daemonsetwindows:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- labelSelector:
matchExpressions:
- key: beta.kubernetes.io/os
operator: In
values:
- windows
## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
Expand Down
66 changes: 66 additions & 0 deletions img/azuremonitor-containers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions kubernetes/linux/acrworkflows/acrdevnamespace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: 1.0-preview-1
steps:
- build: -t {{.Run.Registry}}/public/azuremonitor/containerinsights/cidev:{{.Run.Branch}}-{{.Run.Date}}-{{.Run.Commit | substr 0 7 }} .
workingDirectory: ci_feature
- push: ["{{.Run.Registry}}/public/azuremonitor/containerinsights/cidev:{{.Run.Branch}}-{{.Run.Date}}-{{.Run.Commit | substr 0 7 }}"]
workingDirectory: ci_dev
- push: ["{{.Run.Registry}}/public/azuremonitor/containerinsights/cidev:{{.Run.Branch}}-{{.Run.Date}}-{{.Run.Commit | substr 0 7 }}"]
Loading