Skip to content
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

K8SPSMDB-938: Allow configuring hostAliases for pods (#1236) #1251

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -9637,6 +9648,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -14417,6 +14439,17 @@ spec:
servicePerPod:
type: boolean
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostPort:
format: int32
type: integer
Expand Down
33 changes: 33 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -10240,6 +10251,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -15020,6 +15042,17 @@ spec:
servicePerPod:
type: boolean
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostPort:
format: int32
type: integer
Expand Down
34 changes: 34 additions & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,30 @@ spec:
# rack: rack-22
# nodeSelector:
# disktype: ssd
# schedulerName: "default"
resources:
limits:
cpu: "300m"
memory: "0.5G"
requests:
cpu: "300m"
memory: "0.5G"
volumeSpec:
# emptyDir: {}
# hostPath:
# path: /data
# type: Directory
persistentVolumeClaim:
# storageClassName: standard
# accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 3Gi
# hostAliases:
# - ip: "10.10.0.2"
# hostnames:
# - "host1"
# - "host2"

sharding:
enabled: true
Expand Down Expand Up @@ -374,6 +398,11 @@ spec:
resources:
requests:
storage: 3Gi
# hostAliases:
# - ip: "10.10.0.2"
# hostnames:
# - "host1"
# - "host2"

mongos:
size: 3
Expand Down Expand Up @@ -442,6 +471,11 @@ spec:
# service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
# serviceLabels:
# rack: rack-22
# hostAliases:
# - ip: "10.10.0.2"
# hostnames:
# - "host1"
# - "host2"

backup:
enabled: true
Expand Down
33 changes: 33 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -10240,6 +10251,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -15020,6 +15042,17 @@ spec:
servicePerPod:
type: boolean
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostPort:
format: int32
type: integer
Expand Down
33 changes: 33 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -10240,6 +10251,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -15020,6 +15042,17 @@ spec:
servicePerPod:
type: boolean
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostPort:
format: int32
type: integer
Expand Down
33 changes: 33 additions & 0 deletions e2e-tests/version-service/conf/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3477,6 +3477,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -10240,6 +10251,17 @@ spec:
- votes
type: object
type: array
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -15020,6 +15042,17 @@ spec:
servicePerPod:
type: boolean
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostPort:
format: int32
type: integer
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/psmdb/v1/psmdb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ type ReplsetSpec struct {
Configuration MongoConfiguration `json:"configuration,omitempty"`
ExternalNodes []*ExternalNode `json:"externalNodes,omitempty"`
NonVoting NonVotingSpec `json:"nonvoting,omitempty"`
HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"`
}

func (r *ReplsetSpec) ServiceName(cr *PerconaServerMongoDB) string {
Expand Down Expand Up @@ -586,6 +587,7 @@ type MongosSpec struct {
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
Configuration MongoConfiguration `json:"configuration,omitempty"`
HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"`
}

type MongosSpecSetParameter struct {
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/psmdb/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/psmdb/mongos.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func MongosTemplateSpec(cr *api.PerconaServerMongoDB, initImage string, log logr
Annotations: annotations,
},
Spec: corev1.PodSpec{
HostAliases: cr.Spec.Sharding.Mongos.HostAliases,
SecurityContext: cr.Spec.Sharding.Mongos.PodSecurityContext,
Affinity: PodAffinity(cr, cr.Spec.Sharding.Mongos.MultiAZ.Affinity, ls),
NodeSelector: cr.Spec.Sharding.Mongos.MultiAZ.NodeSelector,
Expand Down
1 change: 1 addition & 0 deletions pkg/psmdb/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func StatefulSpec(ctx context.Context, cr *api.PerconaServerMongoDB, replset *ap
Annotations: annotations,
},
Spec: corev1.PodSpec{
HostAliases: replset.HostAliases,
SecurityContext: podSecurityContext,
Affinity: PodAffinity(cr, multiAZ.Affinity, customLabels),
NodeSelector: multiAZ.NodeSelector,
Expand Down
Loading