Created
May 10, 2020 19:29
-
-
Save achoimet/cf84a4c199ad29b6c7ff4bce5baaf961 to your computer and use it in GitHub Desktop.
create deployment in go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createDeployment(clientAppsV1 typedappsv1.AppsV1Interface) error { | |
deployment := &appsv1.Deployment{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: appName, | |
Labels: map[string]string{ | |
"app": appName, | |
}, | |
}, | |
Spec: appsv1.DeploymentSpec{ | |
Replicas: pointer.Int32Ptr(1), | |
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{ | |
"app": appName, | |
}}, | |
Template: corev1.PodTemplateSpec{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: appName, | |
Labels: map[string]string{ | |
"app": appName, | |
}, | |
}, | |
Spec: corev1.PodSpec{Containers: []corev1.Container{ | |
{ | |
Name: appName, | |
Image: "achoimet/gkbm", | |
Ports: []corev1.ContainerPort{{Name: "http", ContainerPort: 3000}}, | |
ImagePullPolicy: corev1.PullAlways, | |
}, | |
}}, | |
}, | |
}, | |
} | |
_, err := clientAppsV1.Deployments(appName).Create(deployment) | |
if err != nil { | |
return err | |
} | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment