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

operator: Add memberlist IPv6 support #10562

Merged
merged 16 commits into from
Oct 2, 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
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [10562](https://github.com/grafana/loki/pull/10562) **periklis**: Add memberlist IPv6 support
- [10720](https://github.com/grafana/loki/pull/10720) **JoaoBraveCoding**: Change default replication factor of 1x.medium to 2
- [10600](https://github.com/grafana/loki/pull/10600) **periklis**: Update Loki operand to v2.9.1
- [10545](https://github.com/grafana/loki/pull/10545) **xperimental**: Update gateway arguments to enable namespace extraction
Expand Down
10 changes: 10 additions & 0 deletions operator/apis/loki/v1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ type MemberListSpec struct {
// +kubebuilder:validation:optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:select:default","urn:alm:descriptor:com.tectonic.ui:select:podIP"},displayName="Instance Address"
InstanceAddrType InstanceAddrType `json:"instanceAddrType,omitempty"`

// EnableIPv6 enables IPv6 support for the memberlist based hash ring.
//
// Currently this also forces the instanceAddrType to podIP to avoid local address lookup
// for the memberlist.
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch",displayName="Enable IPv6"
EnableIPv6 bool `json:"enableIPv6,omitempty"`
}

// HashRingSpec defines the hash ring configuration
Expand Down
2 changes: 2 additions & 0 deletions operator/apis/loki/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ var (
ErrReplicationFactorToZonesRatio = errors.New("replication factor is greater than the number of available zones")
// ErrReplicationSpecConflict when both the ReplicationSpec and depricated ReplicationFactor are used.
ErrReplicationSpecConflict = errors.New("replicationSpec and replicationFactor (deprecated) cannot be used at the same time")
// ErrIPv6InstanceAddrTypeNotAllowed when the default InstanceAddrType is used with enableIPv6.
ErrIPv6InstanceAddrTypeNotAllowed = errors.New(`instanceAddrType "default" cannot be used with enableIPv6 at the same time`)

// ErrRuleMustMatchNamespace indicates that an expression used in an alerting or recording rule is missing
// matchers for a namespace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.4.0
createdAt: "2023-09-15T08:01:24Z"
createdAt: "2023-09-28T10:58:47Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
operators.operatorframework.io/builder: operator-sdk-unknown
Expand Down Expand Up @@ -265,6 +265,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
memberlist:
description: MemberList configuration spec
properties:
enableIPv6:
description: "EnableIPv6 enables IPv6 support for the memberlist
based hash ring. \n Currently this also forces the instanceAddrType
to podIP to avoid local address lookup for the memberlist."
type: boolean
instanceAddrType:
description: InstanceAddrType defines the type of address
to use to advertise to the ring. Defaults to the first address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.4.0
createdAt: "2023-09-15T08:01:22Z"
createdAt: "2023-09-28T10:58:45Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
operators.operatorframework.io/builder: operator-sdk-unknown
Expand Down Expand Up @@ -265,6 +265,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
memberlist:
description: MemberList configuration spec
properties:
enableIPv6:
description: "EnableIPv6 enables IPv6 support for the memberlist
based hash ring. \n Currently this also forces the instanceAddrType
to podIP to avoid local address lookup for the memberlist."
type: boolean
instanceAddrType:
description: InstanceAddrType defines the type of address
to use to advertise to the ring. Defaults to the first address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: quay.io/openshift-logging/loki-operator:0.1.0
createdAt: "2023-09-15T08:01:27Z"
createdAt: "2023-09-28T10:58:49Z"
description: |
The Loki Operator for OCP provides a means for configuring and managing a Loki stack for cluster logging.
## Prerequisites and Requirements
Expand Down Expand Up @@ -278,6 +278,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
memberlist:
description: MemberList configuration spec
properties:
enableIPv6:
description: "EnableIPv6 enables IPv6 support for the memberlist
based hash ring. \n Currently this also forces the instanceAddrType
to podIP to avoid local address lookup for the memberlist."
type: boolean
instanceAddrType:
description: InstanceAddrType defines the type of address
to use to advertise to the ring. Defaults to the first address
Expand Down
5 changes: 5 additions & 0 deletions operator/config/crd/bases/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ spec:
memberlist:
description: MemberList configuration spec
properties:
enableIPv6:
description: "EnableIPv6 enables IPv6 support for the memberlist
based hash ring. \n Currently this also forces the instanceAddrType
to podIP to avoid local address lookup for the memberlist."
type: boolean
instanceAddrType:
description: InstanceAddrType defines the type of address
to use to advertise to the ring. Defaults to the first address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ spec:
- description: MemberList configuration spec
displayName: Memberlist Config
path: hashRing.memberlist
- description: "EnableIPv6 enables IPv6 support for the memberlist based hash
ring. \n Currently this also forces the instanceAddrType to podIP to avoid
local address lookup for the memberlist."
displayName: Enable IPv6
path: hashRing.memberlist.enableIPv6
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
- description: InstanceAddrType defines the type of address to use to advertise
to the ring. Defaults to the first address from any private network interfaces
of the current pod. Alternatively the public pod IP can be used in case
Expand Down
14 changes: 14 additions & 0 deletions operator/docs/operator/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,20 @@ Alternatively the public pod IP can be used in case private networks (RFC 1918 a
are not available.</p>
</td>
</tr>
<tr>
<td>
<code>enableIPv6</code><br/>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>EnableIPv6 enables IPv6 support for the memberlist based hash ring.</p>
<p>Currently this also forces the instanceAddrType to podIP to avoid local address lookup
for the memberlist.</p>
</td>
</tr>
</tbody>
</table>

Expand Down
16 changes: 14 additions & 2 deletions operator/internal/manifests/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,31 @@ func alertManagerConfig(spec *lokiv1.AlertManagerSpec) *config.AlertManagerConfi
}

func gossipRingConfig(stackName, stackNs string, spec *lokiv1.HashRingSpec, replication *lokiv1.ReplicationSpec) config.GossipRing {
var instanceAddr string
var (
instanceAddr string
enableIPv6 bool
)
if spec != nil && spec.Type == lokiv1.HashRingMemberList && spec.MemberList != nil {
switch spec.MemberList.InstanceAddrType {
case lokiv1.InstanceAddrPodIP:
instanceAddr = fmt.Sprintf("${%s}", gossipInstanceAddrEnvVarName)
instanceAddr = gossipInstanceAddrEnvVarTemplate
case lokiv1.InstanceAddrDefault:
// Do nothing use loki defaults
default:
// Do nothing use loki defaults
}

// Always default to use the pod IP address when IPv6 enabled to ensure:
// - On Single Stack IPv6: Skip interface checking
// - On Dual Stack IPv4/6: Eliminate duplicate memberlist node registration
if spec.MemberList.EnableIPv6 {
periklis marked this conversation as resolved.
Show resolved Hide resolved
enableIPv6 = true
instanceAddr = gossipInstanceAddrEnvVarTemplate
}
}

return config.GossipRing{
EnableIPv6: enableIPv6,
InstanceAddr: instanceAddr,
InstancePort: grpcPort,
BindPort: gossipPort,
Expand Down
37 changes: 37 additions & 0 deletions operator/internal/manifests/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,43 @@ func TestConfigOptions_GossipRingConfig(t *testing.T) {
MembersDiscoveryAddr: "my-stack-gossip-ring.my-ns.svc.cluster.local",
},
},
{
desc: "IPv6 enabled with default instance address type",
spec: lokiv1.LokiStackSpec{
HashRing: &lokiv1.HashRingSpec{
Type: lokiv1.HashRingMemberList,
MemberList: &lokiv1.MemberListSpec{
EnableIPv6: true,
},
},
},
wantOptions: config.GossipRing{
EnableIPv6: true,
InstanceAddr: "${HASH_RING_INSTANCE_ADDR}",
InstancePort: 9095,
BindPort: 7946,
MembersDiscoveryAddr: "my-stack-gossip-ring.my-ns.svc.cluster.local",
},
},
{
desc: "IPv6 enabled with podIP instance address type",
spec: lokiv1.LokiStackSpec{
HashRing: &lokiv1.HashRingSpec{
Type: lokiv1.HashRingMemberList,
MemberList: &lokiv1.MemberListSpec{
EnableIPv6: true,
InstanceAddrType: lokiv1.InstanceAddrPodIP,
},
},
},
wantOptions: config.GossipRing{
EnableIPv6: true,
InstanceAddr: "${HASH_RING_INSTANCE_ADDR}",
InstancePort: 9095,
BindPort: 7946,
MembersDiscoveryAddr: "my-stack-gossip-ring.my-ns.svc.cluster.local",
},
},
}
for _, tc := range tt {
tc := tc
Expand Down
Loading
Loading