Shorten executor kubernetes objects name (#975)
This commit is contained in:
@@ -203,8 +203,8 @@ func (deploy *NewDeploy) getDeploymentSpec(fn *crd.Function, env *crd.Environmen
|
|||||||
|
|
||||||
deployment := &v1beta1.Deployment{
|
deployment := &v1beta1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Labels: deployLabels,
|
|
||||||
Name: deployName,
|
Name: deployName,
|
||||||
|
Labels: deployLabels,
|
||||||
},
|
},
|
||||||
Spec: v1beta1.DeploymentSpec{
|
Spec: v1beta1.DeploymentSpec{
|
||||||
Replicas: &replicas,
|
Replicas: &replicas,
|
||||||
@@ -405,9 +405,8 @@ func (deploy *NewDeploy) createOrGetHpa(hpaName string, execStrategy *fission.Ex
|
|||||||
if err != nil && k8s_err.IsNotFound(err) {
|
if err != nil && k8s_err.IsNotFound(err) {
|
||||||
hpa := asv1.HorizontalPodAutoscaler{
|
hpa := asv1.HorizontalPodAutoscaler{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: hpaName,
|
Name: hpaName,
|
||||||
Namespace: depl.ObjectMeta.Namespace,
|
Labels: depl.Labels,
|
||||||
Labels: depl.Labels,
|
|
||||||
},
|
},
|
||||||
Spec: asv1.HorizontalPodAutoscalerSpec{
|
Spec: asv1.HorizontalPodAutoscalerSpec{
|
||||||
ScaleTargetRef: asv1.CrossVersionObjectReference{
|
ScaleTargetRef: asv1.CrossVersionObjectReference{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dchest/uniuri"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/api/extensions/v1beta1"
|
"k8s.io/api/extensions/v1beta1"
|
||||||
@@ -547,19 +548,20 @@ func (deploy *NewDeploy) fnDelete(fn *crd.Function) (*fscache.FuncSvc, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (deploy *NewDeploy) getObjName(fn *crd.Function) string {
|
func (deploy *NewDeploy) getObjName(fn *crd.Function) string {
|
||||||
return fmt.Sprintf("%v-%v",
|
return strings.ToLower(fmt.Sprintf("newdeploy-%v-%v-%v",
|
||||||
fn.Metadata.Name,
|
fn.Metadata.Name, fn.Metadata.Namespace, uniuri.NewLen(8)))
|
||||||
deploy.instanceID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (deploy *NewDeploy) getDeployLabels(fn *crd.Function, env *crd.Environment) map[string]string {
|
func (deploy *NewDeploy) getDeployLabels(fn *crd.Function, env *crd.Environment) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"environmentName": env.Metadata.Name,
|
|
||||||
"environmentUid": string(env.Metadata.UID),
|
|
||||||
"functionName": fn.Metadata.Name,
|
|
||||||
"functionUid": string(fn.Metadata.UID),
|
|
||||||
fission.EXECUTOR_INSTANCEID_LABEL: deploy.instanceID,
|
fission.EXECUTOR_INSTANCEID_LABEL: deploy.instanceID,
|
||||||
"executorType": fission.ExecutorTypeNewdeploy,
|
fission.EXECUTOR_TYPE: fission.ExecutorTypeNewdeploy,
|
||||||
|
fission.ENVIRONMENT_NAME: env.Metadata.Name,
|
||||||
|
fission.ENVIRONMENT_NAMESPACE: env.Metadata.Namespace,
|
||||||
|
fission.ENVIRONMENT_UID: string(env.Metadata.UID),
|
||||||
|
fission.FUNCTION_NAME: fn.Metadata.Name,
|
||||||
|
fission.FUNCTION_NAMESPACE: fn.Metadata.Namespace,
|
||||||
|
fission.FUNCTION_UID: string(fn.Metadata.UID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-10
@@ -157,12 +157,7 @@ func MakeGenericPool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Labels for generic deployment/RS/pods.
|
// Labels for generic deployment/RS/pods.
|
||||||
gp.labelsForPool = map[string]string{
|
gp.labelsForPool = gp.getDeployLabels()
|
||||||
"environmentName": gp.env.Metadata.Name,
|
|
||||||
"environmentUid": string(gp.env.Metadata.UID),
|
|
||||||
fission.EXECUTOR_INSTANCEID_LABEL: gp.instanceId,
|
|
||||||
"executorType": fission.ExecutorTypePoolmgr,
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the pool
|
// create the pool
|
||||||
err = gp.createPool()
|
err = gp.createPool()
|
||||||
@@ -176,6 +171,16 @@ func MakeGenericPool(
|
|||||||
return gp, nil
|
return gp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gp *GenericPool) getDeployLabels() map[string]string {
|
||||||
|
return map[string]string{
|
||||||
|
fission.EXECUTOR_INSTANCEID_LABEL: gp.instanceId,
|
||||||
|
fission.EXECUTOR_TYPE: fission.ExecutorTypePoolmgr,
|
||||||
|
fission.ENVIRONMENT_NAME: gp.env.Metadata.Name,
|
||||||
|
fission.ENVIRONMENT_NAMESPACE: gp.env.Metadata.Namespace,
|
||||||
|
fission.ENVIRONMENT_UID: string(gp.env.Metadata.UID),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// choosePodService serializes the choosing of pods
|
// choosePodService serializes the choosing of pods
|
||||||
func (gp *GenericPool) choosePodService() {
|
func (gp *GenericPool) choosePodService() {
|
||||||
for {
|
for {
|
||||||
@@ -456,12 +461,14 @@ func (gp *GenericPool) specializePod(pod *apiv1.Pod, metadata *metav1.ObjectMeta
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gp *GenericPool) getPoolName() string {
|
||||||
|
return strings.ToLower(fmt.Sprintf("poolmgr-%v-%v-%v",
|
||||||
|
gp.env.Metadata.Name, gp.env.Metadata.Namespace, uniuri.NewLen(8)))
|
||||||
|
}
|
||||||
|
|
||||||
// A pool is a deployment of generic containers for an env. This
|
// A pool is a deployment of generic containers for an env. This
|
||||||
// creates the pool but doesn't wait for any pods to be ready.
|
// creates the pool but doesn't wait for any pods to be ready.
|
||||||
func (gp *GenericPool) createPool() error {
|
func (gp *GenericPool) createPool() error {
|
||||||
poolDeploymentName := fmt.Sprintf("%v-%v-%v",
|
|
||||||
gp.env.Metadata.Name, gp.env.Metadata.UID, strings.ToLower(gp.poolInstanceId))
|
|
||||||
|
|
||||||
fetcherResources, err := util.GetFetcherResources()
|
fetcherResources, err := util.GetFetcherResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -484,7 +491,7 @@ func (gp *GenericPool) createPool() error {
|
|||||||
|
|
||||||
deployment := &v1beta1.Deployment{
|
deployment := &v1beta1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: poolDeploymentName,
|
Name: gp.getPoolName(),
|
||||||
Labels: gp.labelsForPool,
|
Labels: gp.labelsForPool,
|
||||||
},
|
},
|
||||||
Spec: v1beta1.DeploymentSpec{
|
Spec: v1beta1.DeploymentSpec{
|
||||||
|
|||||||
@@ -123,6 +123,17 @@ const (
|
|||||||
AllowedFunctionsPerContainerInfinite = fv1.AllowedFunctionsPerContainerInfinite
|
AllowedFunctionsPerContainerInfinite = fv1.AllowedFunctionsPerContainerInfinite
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// executor kubernetes object label key
|
||||||
|
const (
|
||||||
|
ENVIRONMENT_NAMESPACE = "environmentNamespace"
|
||||||
|
ENVIRONMENT_NAME = "environmentName"
|
||||||
|
ENVIRONMENT_UID = "environmentUid"
|
||||||
|
FUNCTION_NAMESPACE = "functionNamespace"
|
||||||
|
FUNCTION_NAME = "functionName"
|
||||||
|
FUNCTION_UID = "functionUid"
|
||||||
|
EXECUTOR_TYPE = "executorType"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ExecutorTypePoolmgr = fv1.ExecutorTypePoolmgr
|
ExecutorTypePoolmgr = fv1.ExecutorTypePoolmgr
|
||||||
ExecutorTypeNewdeploy = fv1.ExecutorTypeNewdeploy
|
ExecutorTypeNewdeploy = fv1.ExecutorTypeNewdeploy
|
||||||
|
|||||||
Reference in New Issue
Block a user