我在ServiceSpec
中添加端口字段时遇到问题。我做错了什么?
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
port := corev1.ServicePort{}
port.Port = 8443
ports := make(corev1.ServicePort, 1)
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "test-webhook-admissions",
Namespace: "test",
Labels: map[string]string{
"app.kubernetes.io/instance": "test",
"app.kubernetes.io/name": "test",
"control-plane": "controller-manager",
},
},
Spec: corev1.ServiceSpec{
Ports: ports, // Not working
Selector: nil,
//ClusterIP: "",
},
}
1条答案
按热度按时间e3bfsja21#
您必须将对象端口附加到切片端口。