Adding support for ACI DNS name labels (#97)

This commit is contained in:
Bhargav Nookala
2018-02-23 14:06:23 -08:00
committed by Robbie Zhang
parent d80dbbe561
commit 6f748f4375
5 changed files with 65 additions and 8 deletions

View File

@@ -284,15 +284,60 @@ Name ResourceGroup ProvisioningState Image
helloworld-2559879000-8vmjw myResourceGroup Succeeded microsoft/aci-helloworld 52.179.3.180:80 1.0 core/1.5 gb Linux eastus
```
### Schedule an ACI pod with a DNS Name label
Add an annotation to your Pod manifest, `virtualkubelet.io/dnsnamelabel` keyed to what you'd like the Azure Container Instance to receive as a DNS Name, and deploy it.
```yaml
apiVersion: v1
kind: Pod
metadata:
name: helloworld
annotations:
virtualkubelet.io/dnsnamelabel: "helloworld-aci"
spec:
containers:
- image: microsoft/aci-helloworld
imagePullPolicy: Always
name: helloworld
resources:
requests:
memory: 1G
cpu: 1
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 443
name: https
dnsPolicy: ClusterFirst
nodeName: virtual-kubelet
```
To confirm the Azure Container Instance received and bound the DNS Name specified, use the [az container show][az-container-show] Azure CLI command. Virtual Kubelet's naming
convention will affect how you use this query, with the argument to `-n` broken down as: nameSpace-podName. Unless specified, Kubernetes will assume
the namespace is `default`.
```azurecli-interactive
az container show -g myResourceGroup -n default-helloworld --query ipAddress.fqdn
```
Output:
```console
"helloworld-aci.westus.azurecontainer.io"
```
## Remove the Virtual Kubelet
You can remove your Virtual Kubelet node, you can delete the Helm deployment, by running the following command:
You can remove your Virtual Kubelet node by deleting the Helm deployment. Run the following command:
```
helm delete virtual-kubelet --purge
```
```
<!-- LINKS -->
[kubectl-create]: https://kubernetes.io/docs/user-guide/kubectl/v1.6/#create
[kubectl-get]: https://kubernetes.io/docs/user-guide/kubectl/v1.8/#get
[az-container-list]: https://docs.microsoft.com/en-us/cli/azure/aks?view=azure-cli-latest#az_aks_list
[az-container-list]: https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_list
[az-container-show]: https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_show

View File

@@ -26,6 +26,8 @@ import (
// The service account secret mount path.
const serviceAccountSecretMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
const virtualKubeletDNSNameLabel = "virtualkubelet.io/dnsnamelabel"
// ACIProvider implements the virtual-kubelet provider interface and communicates with Azure's ACI APIs.
type ACIProvider struct {
aciClient *aci.Client
@@ -231,6 +233,10 @@ func (p *ACIProvider) CreatePod(pod *v1.Pod) error {
Ports: ports,
Type: "Public",
}
if dnsNameLabel := pod.Annotations[virtualKubeletDNSNameLabel]; dnsNameLabel != "" {
containerGroup.ContainerGroupProperties.IPAddress.DNSNameLabel = dnsNameLabel
}
}
podUID := string(pod.UID)

View File

@@ -10,8 +10,8 @@ import (
const (
// BaseURI is the default URI used for compute services.
BaseURI = "https://management.azure.com"
userAgent = "virtual-kubelet/azure-arm-aci/2017-12-01"
apiVersion = "2017-12-01-preview"
userAgent = "virtual-kubelet/azure-arm-aci/2018-02-01"
apiVersion = "2018-02-01-preview"
containerGroupURLPath = "subscriptions/{{.subscriptionId}}/resourceGroups/{{.resourceGroup}}/providers/Microsoft.ContainerInstance/containerGroups/{{.containerGroupName}}"
containerGroupListURLPath = "subscriptions/{{.subscriptionId}}/providers/Microsoft.ContainerInstance/containerGroups"

View File

@@ -172,9 +172,10 @@ type ImageRegistryCredential struct {
// IPAddress is IP address for the container group.
type IPAddress struct {
Ports []Port `json:"ports,omitempty"`
Type string `json:"type,omitempty"`
IP string `json:"ip,omitempty"`
Ports []Port `json:"ports,omitempty"`
Type string `json:"type,omitempty"`
IP string `json:"ip,omitempty"`
DNSNameLabel string `json:"dnsNameLabel,omitempty"`
}
// Logs is the logs.