-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support hostNetwork #774
Support hostNetwork #774
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,26 +103,28 @@ type TidbClusterStatus struct { | |
TiDB TiDBStatus `json:"tidb,omitempty"` | ||
} | ||
|
||
// PodSpec repreresents shared pod fields between PD/TiDB/TiKV | ||
type PodSpec struct { | ||
Replicas int32 `json:"replicas"` | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
HostNetwork bool `json:"hostNetwork,omitempty"` | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been reverted because it cannot pass
|
||
|
||
// PDSpec contains details of PD member | ||
type PDSpec struct { | ||
ContainerSpec | ||
Replicas int32 `json:"replicas"` | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
StorageClassName string `json:"storageClassName,omitempty"` | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
PodSpec | ||
StorageClassName string `json:"storageClassName,omitempty"` | ||
} | ||
|
||
// TiDBSpec contains details of PD member | ||
type TiDBSpec struct { | ||
ContainerSpec | ||
Replicas int32 `json:"replicas"` | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
PodSpec | ||
StorageClassName string `json:"storageClassName,omitempty"` | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
BinlogEnabled bool `json:"binlogEnabled,omitempty"` | ||
MaxFailoverCount int32 `json:"maxFailoverCount,omitempty"` | ||
SeparateSlowLog bool `json:"separateSlowLog,omitempty"` | ||
|
@@ -137,13 +139,9 @@ type TiDBSlowLogTailerSpec struct { | |
// TiKVSpec contains details of PD member | ||
type TiKVSpec struct { | ||
ContainerSpec | ||
Privileged bool `json:"privileged,omitempty"` | ||
Replicas int32 `json:"replicas"` | ||
Affinity *corev1.Affinity `json:"affinity,omitempty"` | ||
NodeSelector map[string]string `json:"nodeSelector,omitempty"` | ||
StorageClassName string `json:"storageClassName,omitempty"` | ||
Tolerations []corev1.Toleration `json:"tolerations,omitempty"` | ||
Annotations map[string]string `json:"annotations,omitempty"` | ||
PodSpec | ||
Privileged bool `json:"privileged,omitempty"` | ||
StorageClassName string `json:"storageClassName,omitempty"` | ||
} | ||
|
||
// TiKVPromGatewaySpec runs as a sidecar with TiKVSpec | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,6 +320,11 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) | |
storageClassName = controller.DefaultStorageClassName | ||
} | ||
|
||
dnsPolicy := corev1.DNSClusterFirst // same as k8s defaults | ||
if tc.Spec.PD.HostNetwork { | ||
dnsPolicy = corev1.DNSClusterFirstWithHostNet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
tikvset := &apps.StatefulSet{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: setName, | ||
|
@@ -339,6 +344,8 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) | |
SchedulerName: tc.Spec.SchedulerName, | ||
Affinity: tc.Spec.TiKV.Affinity, | ||
NodeSelector: tc.Spec.TiKV.NodeSelector, | ||
HostNetwork: tc.Spec.PD.HostNetwork, | ||
DNSPolicy: dnsPolicy, | ||
Containers: []corev1.Container{ | ||
{ | ||
Name: v1alpha1.TiKVMemberType.String(), | ||
|
@@ -366,6 +373,14 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster) | |
}, | ||
}, | ||
}, | ||
{ | ||
Name: "POD_NAME", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
FieldRef: &corev1.ObjectFieldSelector{ | ||
FieldPath: "metadata.name", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "CLUSTER_NAME", | ||
Value: tcName, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use
POD_NAME
instead ofHOSTNAME
environment. In Kubernetes, the hostname in the pod is implicitly set to the host hostname when the pod is running in host network (xref: kubernetes/kubernetes#12893). Currently, there is no way to change this behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POD_NAME
is undefined if using old tidb-operator. To be compatible with old tidb-operator, setPOD_NAME
to$(hostname)
orHOSTNAME
ifPOD_NAME
is undefined.