I am using Azure cloud. I want to push container logs to Azure loganalytics.But before doing it to my existing Azure running container, I thought of giving the below yaml a try from https://learn.microsoft.com/en-us/azure/container-instances/container-instances-log-analytics :
apiVersion: 2019-12-01
location: eastus
name: mycontainergroup001
properties:
containers:
- name: mycontainer001
properties:
environmentVariables: []
image: fluent/fluentd
ports: []
resources:
requests:
cpu: 1.0
memoryInGB: 1.5
osType: Linux
restartPolicy: Always
diagnostics:
logAnalytics:
workspaceId: LOG_ANALYTICS_WORKSPACE_ID
workspaceKey: LOG_ANALYTICS_WORKSPACE_KEY
tags: null
type: Microsoft.ContainerInstance/containerGroups
I am trying to run the above yaml in AKS cluster by executing kubectl apply -f deploy-aci.yaml. I get the below error: error: unable to recognize ".\deploy-aci.yaml": no matches for kind "Microsoft.ContainerInstance/containerGroups" in version "2019-12-01"
API Resources:
kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
endpoints ep v1 true Endpoints
events ev v1 true Event
limitranges limits v1 true LimitRange
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume
pods po v1 true Pod
podtemplates v1 true PodTemplate
replicationcontrollers rc v1 true ReplicationController
resourcequotas quota v1 true ResourceQuota
secrets v1 true Secret
serviceaccounts sa v1 true ServiceAccount
services svc v1 true Service
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition
apiservices apiregistration.k8s.io/v1 false APIService
controllerrevisions apps/v1 true ControllerRevision
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
replicasets rs apps/v1 true ReplicaSet
statefulsets sts apps/v1 true StatefulSet
tokenreviews authentication.k8s.io/v1 false TokenReview
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview
horizontalpodautoscalers hpa autoscaling/v1 true HorizontalPodAutoscaler
cronjobs cj batch/v1 true CronJob
jobs batch/v1 true Job
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest
configs config config.gatekeeper.sh/v1alpha1 true Config
k8sazureallowedcapabilities constraints.gatekeeper.sh/v1beta1 false K8sAzureAllowedCapabilities
k8sazureallowedusersgroups constraints.gatekeeper.sh/v1beta1 false K8sAzureAllowedUsersGroupsk8sazureblockautomounttoken constraints.gatekeeper.sh/v1beta1 false K8sAzureBlockAutomountToken
k8sazureblockdefault constraints.gatekeeper.sh/v1beta1 false K8sAzureBlockDefault
k8sazureblockhostnamespace constraints.gatekeeper.sh/v1beta1 false K8sAzureBlockHostNamespacek8sazurecontainerallowedimages constraints.gatekeeper.sh/v1beta1 false K8sAzureContainerAllowedImages
k8sazurecontainerlimits constraints.gatekeeper.sh/v1beta1 false K8sAzureContainerLimits
k8sazurecontainernoprivilege constraints.gatekeeper.sh/v1beta1 false K8sAzureContainerNoPrivilege
k8sazurecontainernoprivilegeescalation constraints.gatekeeper.sh/v1beta1 false K8sAzureContainerNoPrivilegeEscalation
k8sazuredisallowedcapabilities constraints.gatekeeper.sh/v1beta1 false K8sAzureDisallowedCapabilities
k8sazureenforceapparmor constraints.gatekeeper.sh/v1beta1 false K8sAzureEnforceAppArmor
k8sazurehostfilesystem constraints.gatekeeper.sh/v1beta1 false K8sAzureHostFilesystem
k8sazurehostnetworkingports constraints.gatekeeper.sh/v1beta1 false K8sAzureHostNetworkingPorts
k8sazureingresshttpsonly constraints.gatekeeper.sh/v1beta1 false K8sAzureIngressHttpsOnly
k8sazurereadonlyrootfilesystem constraints.gatekeeper.sh/v1beta1 false K8sAzureReadOnlyRootFilesystem
k8sazureserviceallowedports constraints.gatekeeper.sh/v1beta1 false K8sAzureServiceAllowedPorts
leases coordination.k8s.io/v1 true Lease
endpointslices discovery.k8s.io/v1 true EndpointSlice
events ev events.k8s.io/v1 true Event
ingresses ing extensions/v1beta1 true Ingress
flowschemas flowcontrol.apiserver.k8s.io/v1beta1 false FlowSchema
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta1 false PriorityLevelConfigurationingressclasses networking.k8s.io/v1 false IngressClass
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy
runtimeclasses node.k8s.io/v1 false RuntimeClass
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass
secretproviderclasses secrets-store.csi.x-k8s.io/v1 true SecretProviderClass
secretproviderclasspodstatuses secrets-store.csi.x-k8s.io/v1 true SecretProviderClassPodStatus
volumesnapshotclasses snapshot.storage.k8s.io/v1 false VolumeSnapshotClass
volumesnapshotcontents snapshot.storage.k8s.io/v1 false VolumeSnapshotContent
volumesnapshots snapshot.storage.k8s.io/v1 true VolumeSnapshot
constraintpodstatuses status.gatekeeper.sh/v1beta1 true ConstraintPodStatus
constrainttemplatepodstatuses status.gatekeeper.sh/v1beta1 true ConstraintTemplatePodStatus
csidrivers storage.k8s.io/v1 false CSIDriver
csinodes storage.k8s.io/v1 false CSINode
csistoragecapacities storage.k8s.io/v1beta1 true CSIStorageCapacity
storageclasses sc storage.k8s.io/v1 false StorageClass
volumeattachments storage.k8s.io/v1 false VolumeAttachment
constrainttemplates constraints templates.gatekeeper.sh/v1 false ConstraintTemplate
Out of the above apiresources , can I use any of them which would enables the execution of deploy-aci.yaml.
My kubernetes version is 1.21.7.
This YAML won't be run in AKS cluster by executinkubectl apply -f deploy-aci.yaml
. You have to make changes in your YAML code to make it run on AKS.
For Your infomation this YAML code specially writes for create Azure Container Instance and store the logs of Container in Log Analytics WorkSpace.
Also for AKS by default a Log Analytics WorkSpace created while creating AKS.So all the logs of pods/conatainer stored that workspace you don't need to create another workspace to store the logs.
So, Inspite of running kubectl apply -f deploy-aci.yaml
cmdlet please run az container create --resource-group myResourceGroup --name mycontainergroup001 --file deploy-aci.yaml
this cmdlet as given in the MS Document.
I also ran the same command and it has run succesfully and created a container instance.