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-1014: update cert-manager certs and issuers #1383

Merged
merged 26 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1121bd3
K8SPSMDB-1014: update cert-manager certs and issuers
pooknull Nov 27, 2023
0a10322
fix
pooknull Nov 29, 2023
143979e
Fix upgrade from `1.14.0`
pooknull Dec 6, 2023
e6e82dd
Merge branch 'main' into dev/K8SPSMDB-1014
pooknull Dec 7, 2023
88f8f8a
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Mar 8, 2024
794272e
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Mar 26, 2024
9120947
fix test
pooknull Mar 26, 2024
106f629
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Mar 27, 2024
11072e2
fix merge
pooknull Mar 27, 2024
05482e5
update `upgrade-consistency-sharded-tls`
pooknull Mar 28, 2024
0669a10
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Mar 28, 2024
a895b86
fix `TestReconcileStatefulSet`
pooknull Mar 28, 2024
7b359f6
Merge branch 'main' into dev/K8SPSMDB-1014
nmarukovich Apr 10, 2024
e9699d5
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Apr 12, 2024
c0e9a92
Merge branch 'main' into dev/K8SPSMDB-1014
pooknull Apr 15, 2024
fc2f589
fix test
pooknull Apr 15, 2024
6ebe9d0
Merge branch 'main' into dev/K8SPSMDB-1014
hors Apr 15, 2024
9ce0ec4
Merge branch 'main' into dev/K8SPSMDB-1014
hors Apr 15, 2024
2b52254
don't use dry controller for deleting deprecated issuer
pooknull Apr 16, 2024
8bf223d
rename variables
pooknull Apr 16, 2024
e225c56
Merge remote-tracking branch 'origin/main' into dev/K8SPSMDB-1014
pooknull Apr 18, 2024
8264390
fix
pooknull Apr 22, 2024
0b19b18
check if sharding is enabled
pooknull Apr 22, 2024
8415038
Merge branch 'main' into dev/K8SPSMDB-1014
pooknull Apr 22, 2024
35c553e
rename `isAllStsHasLatestSSL`
pooknull Apr 22, 2024
f7f2d8d
Merge branch 'main' into dev/K8SPSMDB-1014
tplavcic Apr 22, 2024
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
20 changes: 3 additions & 17 deletions clientcmd/clientcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"k8s.io/client-go/kubernetes/scheme"
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/remotecommand"
)

Expand All @@ -17,29 +16,16 @@ type Client struct {
restconfig *restclient.Config
}

func NewClient() (*Client, error) {
// Instantiate loader for kubeconfig file.
kubeconfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
clientcmd.NewDefaultClientConfigLoadingRules(),
&clientcmd.ConfigOverrides{},
)

// Get a rest.Config from the kubeconfig file. This will be passed into all
// the client objects we create.
restconfig, err := kubeconfig.ClientConfig()
if err != nil {
return nil, err
}

func NewClient(config *restclient.Config) (*Client, error) {
// Create a Kubernetes core/v1 client.
cl, err := corev1client.NewForConfig(restconfig)
cl, err := corev1client.NewForConfig(config)
if err != nil {
return nil, err
}

return &Client{
client: cl,
restconfig: restconfig,
restconfig: config,
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations: {}
generation: 1
name: some-name-ssl-internal
ownerReferences:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations: {}
generation: 1
name: some-name-ssl
ownerReferences:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
annotations: {}
generation: 1
name: some-name-psmdb-ca-issuer
ownerReferences:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
annotations: {}
generation: 1
name: some-name-psmdb-issuer
ownerReferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
generation: 5
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 7
generation: 5
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 10
generation: 8
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 10
generation: 8
labels:
app.kubernetes.io/component: cfg
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 8
generation: 5
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 8
generation: 5
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 11
generation: 8
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
generation: 11
generation: 8
inelpandzic marked this conversation as resolved.
Show resolved Hide resolved
labels:
app.kubernetes.io/component: mongod
app.kubernetes.io/instance: some-name
Expand Down
45 changes: 16 additions & 29 deletions e2e-tests/upgrade-consistency-sharded-tls/run
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ main() {
compare_generation "1" "statefulset" "${CLUSTER}-rs0"
compare_generation "1" "statefulset" "${CLUSTER}-cfg"

# TODO: uncomment when 1.14.0 will be removed,
# renewal doesn't work on "1.14.0" version
# Renewal doesn't work on "1.14.0" version
#
#renew_certificate "some-name-ssl"
#renew_certificate "some-name-ssl-internal"
#wait_cluster
Expand All @@ -46,29 +46,16 @@ main() {
compare_kubectl statefulset/${CLUSTER}-cfg "-1140"

desc 'test 1.15.0'
# workaround to switch to updated certificate structure
# more details: https://github.com/percona/percona-server-mongodb-operator/pull/1287
# TODO: remove the workaround when 1.14.0 will be removed
stop_cluster $CLUSTER

compare_generation "4" "statefulset" "${CLUSTER}-rs0"
compare_generation "3" "statefulset" "${CLUSTER}-cfg"

kubectl_bin patch psmdb "${CLUSTER}" --type=merge --patch '{
"spec": {"crVersion":"1.15.0"}
}'
# Wait for at least one reconciliation
sleep 20
desc 'check if Pod started'
wait_cluster

compare_generation "5" "statefulset" "${CLUSTER}-rs0"
compare_generation "4" "statefulset" "${CLUSTER}-cfg"

kubectl_bin delete certificate "$CLUSTER"-ssl "$CLUSTER"-ssl-internal
kubectl_bin delete issuer "$CLUSTER-psmdb-ca"
kubectl_bin delete secret "$CLUSTER"-ssl "$CLUSTER"-ssl-internal
start_cluster $CLUSTER
compare_generation "6" "statefulset" "${CLUSTER}-rs0"
compare_generation "5" "statefulset" "${CLUSTER}-cfg"
compare_generation "3" "statefulset" "${CLUSTER}-rs0"
compare_generation "3" "statefulset" "${CLUSTER}-cfg"

# Wait for at least one reconciliation
sleep 20
Expand All @@ -78,14 +65,14 @@ main() {
renew_certificate "some-name-ssl"
sleep 20
wait_cluster
compare_generation "7" "statefulset" "${CLUSTER}-rs0"
compare_generation "6" "statefulset" "${CLUSTER}-cfg"
compare_generation "4" "statefulset" "${CLUSTER}-rs0"
compare_generation "4" "statefulset" "${CLUSTER}-cfg"

renew_certificate "some-name-ssl-internal"
sleep 20
wait_cluster
compare_generation "8" "statefulset" "${CLUSTER}-rs0"
compare_generation "7" "statefulset" "${CLUSTER}-cfg"
compare_generation "5" "statefulset" "${CLUSTER}-rs0"
compare_generation "5" "statefulset" "${CLUSTER}-cfg"

desc 'check if service and statefulset created with expected config'
compare_kubectl service/${CLUSTER}-rs0 "-1150"
Expand All @@ -101,20 +88,20 @@ main() {
sleep 20
desc 'check if Pod started'
wait_cluster
compare_generation "9" "statefulset" "${CLUSTER}-rs0"
compare_generation "8" "statefulset" "${CLUSTER}-cfg"
compare_generation "6" "statefulset" "${CLUSTER}-rs0"
compare_generation "6" "statefulset" "${CLUSTER}-cfg"

renew_certificate "some-name-ssl"
sleep 20
wait_cluster
compare_generation "10" "statefulset" "${CLUSTER}-rs0"
compare_generation "9" "statefulset" "${CLUSTER}-cfg"
compare_generation "7" "statefulset" "${CLUSTER}-rs0"
compare_generation "7" "statefulset" "${CLUSTER}-cfg"

renew_certificate "some-name-ssl-internal"
sleep 20
wait_cluster
compare_generation "11" "statefulset" "${CLUSTER}-rs0"
compare_generation "10" "statefulset" "${CLUSTER}-cfg"
compare_generation "8" "statefulset" "${CLUSTER}-rs0"
compare_generation "8" "statefulset" "${CLUSTER}-cfg"

desc 'check if service and statefulset created with expected config'
compare_kubectl service/${CLUSTER}-rs0 "-1160"
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/psmdb/v1/perconaservermongodbrestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,8 @@ var (
PITRestoreTypeLatest PITRestoreType = "latest"
)

const AnnotationRestoreInProgress = "percona.com/restore-in-progress"
const (
AnnotationRestoreInProgress = "percona.com/restore-in-progress"
// AnnotationUpdateMongosFirst is an annotation used to force next smart update to be applied to mongos before mongod.
AnnotationUpdateMongosFirst = "percona.com/update-mongos-first"
)
8 changes: 8 additions & 0 deletions pkg/apis/psmdb/v1/psmdb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,14 @@ type SecretsSpec struct {
LDAPSecret string `json:"ldapSecret,omitempty"`
}

func SSLSecretName(cr *PerconaServerMongoDB) string {
return cr.Spec.Secrets.SSL
}

func SSLInternalSecretName(cr *PerconaServerMongoDB) string {
return cr.Spec.Secrets.SSLInternal
}

type MongosSpec struct {
MultiAZ `json:",inline"`

Expand Down
Loading
Loading