-
Notifications
You must be signed in to change notification settings - Fork 499
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
Conversation
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 comment
The reason will be displayed to describe this comment to others. Learn more.
PodSpec
is created to simplify code only. Only one field hostNetwork
is introduced.
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.
This has been reverted because it cannot pass go vet
check.
pkg/apis/pingcap.com/v1alpha1/tidbcluster_test.go:180:5: cannot use promoted field PodSpec.Replicas in struct literal of type PDSpec
pkg/apis/pingcap.com/v1alpha1/tidbcluster_test.go:183:5: cannot use promoted field PodSpec.Replicas in struct literal of type TiKVSpec
pkg/apis/pingcap.com/v1alpha1/tidbcluster_test.go:186:5: cannot use promoted field PodSpec.Replicas in struct literal of type TiDBSpec
...
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
DNSClusterFirstWithHostNet
is required in the host network, see https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy. Otherwise, the DNS resolver is the same as the host. Our components cannot resolve Kubernetes DNS names.
@@ -30,7 +30,7 @@ fi | |||
|
|||
# the general form of variable PEER_SERVICE_NAME is: "<clusterName>-pd-peer" | |||
cluster_name=`echo ${PEER_SERVICE_NAME} | sed 's/-pd-peer//'` | |||
domain="${HOSTNAME}.${PEER_SERVICE_NAME}.${NAMESPACE}.svc" | |||
domain="${POD_NAME}.${PEER_SERVICE_NAME}.${NAMESPACE}.svc" |
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 of HOSTNAME
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, set POD_NAME
to $(hostname)
or HOSTNAME
if POD_NAME
is undefined.
Add a case in stability test? |
Sure, I'll add a stability test. |
I removed the |
The stability test is under development, I'll update this PR soon. |
/run-e2e-in-kind |
/run-e2e-in-kind |
I've added a test in e2e. @weekface @tennix @xiaojingchen @gregwebs PTAL. |
/run-e2e-in-kind |
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.
LGTM
In this mode, the pod should be set with anti-affinity to disable two pods scheduled on the same node. This should be added to dev document. |
cherry pick to release-1.0 in PR #798 |
* Support hostNetwork * Use POD_NAME instead of HOSTNAME * Update chart * e2e test * remove PodSpec
* Support hostNetwork * Use POD_NAME instead of HOSTNAME * Update chart * e2e test * remove PodSpec
* .github: add 2 exempt issue labels Signed-off-by: Ran <huangran@pingcap.com> * Update .github/workflows/stale.yaml
What problem does this PR solve?
This adds a new filed in PDSpec/TiKVSpec/TiDBSpec to make it possible to run TiDB components (pd, tikv, tidb) in the host network.
fix #759
What is changed and how does it work?
Check List
Tests
Code changes
Does this PR introduce a user-facing change?: