README
¶
Sidecar injector webhook
This executable implements a MutationAdmissionWebhook server that injects pods with AWS App Mesh sidecar proxies.
The server is called by the Kubernetes API server each time a pod creation event occurs. The server determines
whether the to-be-created pod needs to be patched with the sidecar.
Detailed flow
Following are the steps the server executes when it receives a AdmissionReview request for a pod creation.
- List all the
MeshCRDs in the cluster and select the ones that:- are of type matching AWS App Mesh, and
- have the
EnableAutoInjectflag set to true
- For each of the selected meshes, check if the pod matches the
InjectionSelectorspecified for the given mesh:- if it does not match any mesh, admit the pod without patching it
- if it matches multiple meshes return an error, as multiple injection is currently not supported
- if it matches a mesh, continue
- Retrieve the
SidecarPatchConfigMapspecified in the mesh CRD. This config map contains the template for the patch that will be applied to the pod. A missing or non-existingSidecarPatchConfigMapwhenEnableAutoInjectistruewill cause an error to be returned. - Retrieve the
VirtualNodeLabelfrom the mesh CRD. The webhook will look for this label on the pod and use its value as the name of the Virtual Node that the pod is associated with. The Virtual Node does not have to exist at this point. A missingVirtualNodeLabelwhenEnableAutoInjectistruewill cause an error to be returned. - The patch template is rendered with the following values:
MeshName:nameof the mesh CRD, used to build theAPPMESH_VIRTUAL_NODE_NAMEenv that is set on the sidecar proxy container.VirtualNodeName: value of the pod label with key equal toVirtualNodeLabel. Also used to build theAPPMESH_VIRTUAL_NODE_NAMEenv.AwsRegion:Regionof theMeshCRD; indicates the AWS region where the control plane for the mesh is located.AppPort: thecontainerPorts of the containers in the pod. Will be used as value for theAPPMESH_APP_PORTSenv that is set on theInitContainerthat will be added to the pod specification.
- Convert the rendered patch to the JSONPatch format expected by the Kubernetes API server.
- Set the resulting
JSONPatchon the response and return. The Kubernetes API server will apply the patch to the original pod spec.
Limitations
The sidecar injector webhook currently has the following limitations:
- Pods must match at most one
Mesh - Each container in the input pod must specify a
containerPort InjectionSelectormust be of typeLabelorNamespace(Upstreamsis currently not supported)- AWS App Mesh is currently available only in the following AWS regions:
- ap-south-1,
- ap-northeast-1
- ap-northeast-2
- ap-southeast-1
- ap-southeast-2
- us-west-1
- us-west-2
- us-east-1
- us-east-2
- eu-west-1
- eu-central-1
- ca-central-1
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.