Adding support for ACI DNS name labels (#97)
This commit is contained in:
committed by
Robbie Zhang
parent
d80dbbe561
commit
6f748f4375
@@ -58,6 +58,7 @@ a `virtual-kubelet` node.
|
|||||||
* Environment variables
|
* Environment variables
|
||||||
* Public IPs
|
* Public IPs
|
||||||
* kubectl logs
|
* kubectl logs
|
||||||
|
* DNS name labels
|
||||||
|
|
||||||
## Current Limitations
|
## Current Limitations
|
||||||
|
|
||||||
@@ -116,6 +117,10 @@ You can find detailed instructions on how to set it up and how to test it in the
|
|||||||
The Azure connector can use a configuration file specified by the `--provider-config` flag.
|
The Azure connector can use a configuration file specified by the `--provider-config` flag.
|
||||||
The config file is in TOML format, and an example lives in `providers/azure/example.toml`.
|
The config file is in TOML format, and an example lives in `providers/azure/example.toml`.
|
||||||
|
|
||||||
|
#### More Details
|
||||||
|
|
||||||
|
See the [ACI Readme](providers/azure/README.md)
|
||||||
|
|
||||||
### Hyper.sh Provider
|
### Hyper.sh Provider
|
||||||
|
|
||||||
The Hyper.sh Provider allows Kubernetes clusters to deploy Hyper.sh containers
|
The Hyper.sh Provider allows Kubernetes clusters to deploy Hyper.sh containers
|
||||||
|
|||||||
@@ -284,9 +284,53 @@ 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
|
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
|
## 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
|
helm delete virtual-kubelet --purge
|
||||||
@@ -295,4 +339,5 @@ helm delete virtual-kubelet --purge
|
|||||||
<!-- LINKS -->
|
<!-- LINKS -->
|
||||||
[kubectl-create]: https://kubernetes.io/docs/user-guide/kubectl/v1.6/#create
|
[kubectl-create]: https://kubernetes.io/docs/user-guide/kubectl/v1.6/#create
|
||||||
[kubectl-get]: https://kubernetes.io/docs/user-guide/kubectl/v1.8/#get
|
[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
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import (
|
|||||||
// The service account secret mount path.
|
// The service account secret mount path.
|
||||||
const serviceAccountSecretMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
|
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.
|
// ACIProvider implements the virtual-kubelet provider interface and communicates with Azure's ACI APIs.
|
||||||
type ACIProvider struct {
|
type ACIProvider struct {
|
||||||
aciClient *aci.Client
|
aciClient *aci.Client
|
||||||
@@ -231,6 +233,10 @@ func (p *ACIProvider) CreatePod(pod *v1.Pod) error {
|
|||||||
Ports: ports,
|
Ports: ports,
|
||||||
Type: "Public",
|
Type: "Public",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dnsNameLabel := pod.Annotations[virtualKubeletDNSNameLabel]; dnsNameLabel != "" {
|
||||||
|
containerGroup.ContainerGroupProperties.IPAddress.DNSNameLabel = dnsNameLabel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
podUID := string(pod.UID)
|
podUID := string(pod.UID)
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
// BaseURI is the default URI used for compute services.
|
// BaseURI is the default URI used for compute services.
|
||||||
BaseURI = "https://management.azure.com"
|
BaseURI = "https://management.azure.com"
|
||||||
userAgent = "virtual-kubelet/azure-arm-aci/2017-12-01"
|
userAgent = "virtual-kubelet/azure-arm-aci/2018-02-01"
|
||||||
apiVersion = "2017-12-01-preview"
|
apiVersion = "2018-02-01-preview"
|
||||||
|
|
||||||
containerGroupURLPath = "subscriptions/{{.subscriptionId}}/resourceGroups/{{.resourceGroup}}/providers/Microsoft.ContainerInstance/containerGroups/{{.containerGroupName}}"
|
containerGroupURLPath = "subscriptions/{{.subscriptionId}}/resourceGroups/{{.resourceGroup}}/providers/Microsoft.ContainerInstance/containerGroups/{{.containerGroupName}}"
|
||||||
containerGroupListURLPath = "subscriptions/{{.subscriptionId}}/providers/Microsoft.ContainerInstance/containerGroups"
|
containerGroupListURLPath = "subscriptions/{{.subscriptionId}}/providers/Microsoft.ContainerInstance/containerGroups"
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ type IPAddress struct {
|
|||||||
Ports []Port `json:"ports,omitempty"`
|
Ports []Port `json:"ports,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
IP string `json:"ip,omitempty"`
|
IP string `json:"ip,omitempty"`
|
||||||
|
DNSNameLabel string `json:"dnsNameLabel,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logs is the logs.
|
// Logs is the logs.
|
||||||
|
|||||||
Reference in New Issue
Block a user