未验证 提交 7cdf67f9 编写于 作者: Z zryfish 提交者: GitHub

fix generation bug (#2047)

上级 3ff82c72
......@@ -131,6 +131,10 @@ func (h *handler) populateProxyAddress() error {
return nil
}
// Currently, this method works because of serviceaccount/clusterrole/clusterrolebinding already
// created by kubesphere, we don't need to create them again. And it's a little bit inconvenient
// if we want to change the template.
// TODO(jeff): load template from configmap
func (h *handler) generateDefaultDeployment(cluster *v1alpha1.Cluster, w io.Writer) error {
if cluster.Spec.Connection.Type == v1alpha1.ConnectionTypeDirect {
......@@ -143,12 +147,24 @@ func (h *handler) generateDefaultDeployment(cluster *v1alpha1.Cluster, w io.Writ
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "cluster-agent",
Name: "cluster-agent",
Namespace: "kubesphere-system",
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{},
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": "agent",
"app.kubernetes.io/part-of": "tower",
},
},
Strategy: appsv1.DeploymentStrategy{},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{},
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "agent",
"app.kubernetes.io/part-of": "tower",
},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
......
......@@ -61,12 +61,19 @@ kind: Deployment
metadata:
creationTimestamp: null
name: cluster-agent
namespace: kubesphere-system
spec:
selector: {}
selector:
matchLabels:
app: agent
app.kubernetes.io/part-of: tower
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: agent
app.kubernetes.io/part-of: tower
spec:
containers:
- command:
......@@ -146,6 +153,10 @@ func TestGeranteAgentDeployment(t *testing.T) {
t.Fatalf("expecting error %v, got %v", testCase.expectedError, err)
}
}
if diff := cmp.Diff(testCase.expected, buf.String()); len(diff) != 0 {
t.Errorf("%T, got +, expected -, %s", testCase.expected, diff)
}
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册