forked from microsoft/moaw
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Azure-Samples/ignite
Ignite lab
- Loading branch information
Showing
16 changed files
with
2,570 additions
and
1 deletion.
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
24 changes: 24 additions & 0 deletions
24
workshops/operating-aks-automatic/assets/files/appconfigprovider.yaml
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,24 @@ | ||
apiVersion: azconfig.io/v1 | ||
kind: AzureAppConfigurationProvider | ||
metadata: | ||
name: devconfigs | ||
spec: | ||
endpoint: ${AC_ENDPOINT} | ||
configuration: | ||
refresh: | ||
enabled: true | ||
interval: 10s | ||
monitoring: | ||
keyValues: | ||
- key: MyKey1 | ||
target: | ||
configMapName: myconfigmap | ||
auth: | ||
workloadIdentity: | ||
serviceAccountName: ${SA_NAME} | ||
secret: | ||
auth: | ||
workloadIdentity: | ||
serviceAccountName: ${SA_NAME} | ||
target: | ||
secretName: mysecret |
138 changes: 138 additions & 0 deletions
138
workshops/operating-aks-automatic/assets/files/constrainttemplate-as-policy.json
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,138 @@ | ||
{ | ||
"properties": { | ||
"policyType": "Custom", | ||
"mode": "Microsoft.Kubernetes.Data", | ||
"displayName": "Approved registries only", | ||
"description": "This policy requires that all containers in a Kubernetes cluster are sourced from approved container registries.", | ||
"policyRule": { | ||
"if": { | ||
"field": "type", | ||
"in": [ | ||
"Microsoft.ContainerService/managedClusters" | ||
] | ||
}, | ||
"then": { | ||
"effect": "[parameters('effect')]", | ||
"details": { | ||
"templateInfo": { | ||
"sourceType": "Base64Encoded", | ||
"content": "YXBpVmVyc2lvbjogdGVtcGxhdGVzLmdhdGVrZWVwZXIuc2gvdjFiZXRhMQpraW5kOiBDb25zdHJhaW50VGVtcGxhdGUKbWV0YWRhdGE6CiAgbmFtZTogazhzcmVxdWlyZWRyZWdpc3RyeQpzcGVjOgogIGNyZDoKICAgIHNwZWM6CiAgICAgIG5hbWVzOgogICAgICAgIGtpbmQ6IEs4c1JlcXVpcmVkUmVnaXN0cnkKICAgICAgdmFsaWRhdGlvbjoKICAgICAgICBvcGVuQVBJVjNTY2hlbWE6CiAgICAgICAgICBwcm9wZXJ0aWVzOgogICAgICAgICAgICByZWdpc3RyeToKICAgICAgICAgICAgICB0eXBlOiBzdHJpbmcKICB0YXJnZXRzOgogICAgLSB0YXJnZXQ6IGFkbWlzc2lvbi5rOHMuZ2F0ZWtlZXBlci5zaAogICAgICByZWdvOiB8CiAgICAgICAgcGFja2FnZSBrOHNyZXF1aXJlZHJlZ2lzdHJ5CiAgICAgICAgdmlvbGF0aW9uW3sibXNnIjogbXNnLCAiZGV0YWlscyI6IHsiUmVnaXN0cnkgbXVzdCBiZSI6IHJlcXVpcmVkfX1dIHsKICAgICAgICAgIGlucHV0LnJldmlldy5vYmplY3Qua2luZCA9PSAiUG9kIgogICAgICAgICAgc29tZSBpCiAgICAgICAgICBpbWFnZSA6PSBpbnB1dC5yZXZpZXcub2JqZWN0LnNwZWMuY29udGFpbmVyc1tpXS5pbWFnZQogICAgICAgICAgcmVxdWlyZWQgOj0gaW5wdXQucGFyYW1ldGVycy5yZWdpc3RyeQogICAgICAgICAgbm90IHN0YXJ0c3dpdGgoaW1hZ2UscmVxdWlyZWQpCiAgICAgICAgICBtc2cgOj0gc3ByaW50ZigiRm9yYmlkZGVuIHJlZ2lzdHJ5OiAldiIsIFtpbWFnZV0pCiAgICAgICAgfQo=" | ||
}, | ||
"apiGroups": [ | ||
"" | ||
], | ||
"kinds": [ | ||
"Pod" | ||
], | ||
"namespaces": "[parameters('namespaces')]", | ||
"excludedNamespaces": "[parameters('excludedNamespaces')]", | ||
"labelSelector": "[parameters('labelSelector')]", | ||
"values": { | ||
"registry": "[parameters('registry')]" | ||
} | ||
} | ||
} | ||
}, | ||
"parameters": { | ||
"effect": { | ||
"type": "String", | ||
"metadata": { | ||
"displayName": "Effect", | ||
"description": "'audit' allows a non-compliant resource to be created or updated, but flags it as non-compliant. 'deny' blocks the non-compliant resource creation or update. 'disabled' turns off the policy." | ||
}, | ||
"allowedValues": [ | ||
"audit", | ||
"deny", | ||
"disabled" | ||
], | ||
"defaultValue": "audit" | ||
}, | ||
"excludedNamespaces": { | ||
"type": "Array", | ||
"metadata": { | ||
"displayName": "Namespace exclusions", | ||
"description": "List of Kubernetes namespaces to exclude from policy evaluation." | ||
}, | ||
"defaultValue": [ | ||
"kube-system", | ||
"gatekeeper-system", | ||
"azure-arc" | ||
] | ||
}, | ||
"namespaces": { | ||
"type": "Array", | ||
"metadata": { | ||
"displayName": "Namespace inclusions", | ||
"description": "List of Kubernetes namespaces to only include in policy evaluation. An empty list means the policy is applied to all resources in all namespaces." | ||
}, | ||
"defaultValue": [] | ||
}, | ||
"labelSelector": { | ||
"type": "Object", | ||
"metadata": { | ||
"displayName": "Kubernetes label selector", | ||
"description": "Label query to select Kubernetes resources for policy evaluation. An empty label selector matches all Kubernetes resources." | ||
}, | ||
"defaultValue": {}, | ||
"schema": { | ||
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all resources.", | ||
"type": "object", | ||
"properties": { | ||
"matchLabels": { | ||
"description": "matchLabels is a map of {key,value} pairs.", | ||
"type": "object", | ||
"additionalProperties": { | ||
"type": "string" | ||
}, | ||
"minProperties": 1 | ||
}, | ||
"matchExpressions": { | ||
"description": "matchExpressions is a list of values, a key, and an operator.", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"key": { | ||
"description": "key is the label key that the selector applies to.", | ||
"type": "string" | ||
}, | ||
"operator": { | ||
"description": "operator represents a key's relationship to a set of values.", | ||
"type": "string", | ||
"enum": [ | ||
"In", | ||
"NotIn", | ||
"Exists", | ||
"DoesNotExist" | ||
] | ||
}, | ||
"values": { | ||
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"key", | ||
"operator" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"minItems": 1 | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"registry": { | ||
"type": "String", | ||
"metadata": { | ||
"displayName": "Image registry", | ||
"description": "The container image registry to allow." | ||
} | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
workshops/operating-aks-automatic/assets/files/constrainttemplate.yaml
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,26 @@ | ||
apiVersion: templates.gatekeeper.sh/v1beta1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: k8srequiredregistry | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: K8sRequiredRegistry | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
registry: | ||
type: string | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package k8srequiredregistry | ||
violation[{"msg": msg, "details": {"Registry must be": required}}] { | ||
input.review.object.kind == "Pod" | ||
some i | ||
image := input.review.object.spec.containers[i].image | ||
required := input.parameters.registry | ||
not startswith(image,required) | ||
msg := sprintf("Forbidden registry: %v", [image]) | ||
} |
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,27 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
run: mynginx | ||
name: mynginx | ||
spec: | ||
containers: | ||
- image: nginx:latest | ||
name: mynginx | ||
resources: | ||
limits: | ||
cpu: 5m | ||
memory: 4Mi | ||
requests: | ||
cpu: 3m | ||
memory: 2Mi | ||
livenessProbe: | ||
tcpSocket: | ||
port: 80 | ||
initialDelaySeconds: 3 | ||
periodSeconds: 3 | ||
readinessProbe: | ||
tcpSocket: | ||
port: 80 | ||
initialDelaySeconds: 3 | ||
periodSeconds: 3 |
40 changes: 40 additions & 0 deletions
40
workshops/operating-aks-automatic/assets/files/nodepool.yaml
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,40 @@ | ||
apiVersion: karpenter.sh/v1beta1 | ||
kind: NodePool | ||
metadata: | ||
annotations: | ||
kubernetes.io/description: General purpose NodePool for dev workloads | ||
name: devpool | ||
spec: | ||
disruption: | ||
budgets: | ||
- nodes: 100% | ||
consolidationPolicy: WhenUnderutilized | ||
expireAfter: Never | ||
template: | ||
metadata: | ||
labels: | ||
team: dev | ||
spec: | ||
nodeClassRef: | ||
name: default | ||
taints: | ||
- key: team | ||
value: dev | ||
effect: NoSchedule | ||
requirements: | ||
- key: kubernetes.io/arch | ||
operator: In | ||
values: | ||
- arm64 | ||
- key: kubernetes.io/os | ||
operator: In | ||
values: | ||
- linux | ||
- key: karpenter.sh/capacity-type | ||
operator: In | ||
values: | ||
- on-demand | ||
- key: karpenter.azure.com/sku-family | ||
operator: In | ||
values: | ||
- D |
48 changes: 48 additions & 0 deletions
48
workshops/operating-aks-automatic/assets/files/productservice-topologyspread.yaml
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,48 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: product-service | ||
namespace: dev | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: product-service | ||
template: | ||
metadata: | ||
labels: | ||
app: product-service | ||
spec: | ||
containers: | ||
- name: product-service | ||
image: ${ACR_NAME}.azurecr.io/product-service:1.5.2 | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: team | ||
operator: In | ||
values: | ||
- dev | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- product-service | ||
topologyKey: "kubernetes.io/hostname" | ||
tolerations: | ||
- key: "team" | ||
operator: "Equal" | ||
value: "dev" | ||
effect: "NoSchedule" | ||
topologySpreadConstraints: | ||
- maxSkew: 1 | ||
topologyKey: "topology.kubernetes.io/zone" | ||
whenUnsatisfiable: DoNotSchedule | ||
labelSelector: | ||
matchLabels: | ||
app: product-service |
32 changes: 32 additions & 0 deletions
32
workshops/operating-aks-automatic/assets/files/productservice.yaml
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,32 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: product-service | ||
namespace: dev | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: product-service | ||
template: | ||
metadata: | ||
labels: | ||
app: product-service | ||
spec: | ||
containers: | ||
- name: product-service | ||
image: ${ACR_NAME}.azurecr.io/product-service:1.5.2 | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: team | ||
operator: In | ||
values: | ||
- dev | ||
tolerations: | ||
- key: "team" | ||
operator: "Equal" | ||
value: "dev" | ||
effect: "NoSchedule" |
10 changes: 10 additions & 0 deletions
10
workshops/operating-aks-automatic/assets/files/verticalpodautoscaler.yaml
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,10 @@ | ||
apiVersion: "autoscaling.k8s.io/v1" | ||
kind: VerticalPodAutoscaler | ||
metadata: | ||
name: product-service-vpa | ||
namespace: dev | ||
spec: | ||
targetRef: | ||
apiVersion: "apps/v1" | ||
kind: Deployment | ||
name: product-service |
Oops, something went wrong.