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

Use Apps api over extensions #2611

Merged
merged 1 commit into from Feb 14, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Documentation/edgefs-cluster-crd.md
Expand Up @@ -336,7 +336,7 @@ subjects:
name: rook-edgefs-cluster
namespace: rook-edgefs
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: PodSecurityPolicy
metadata:
name: privileged
Expand Down Expand Up @@ -364,7 +364,7 @@ metadata:
name: privileged-psp-user
rules:
- apiGroups:
- extensions
- apps
resources:
- podsecuritypolicies
resourceNames:
Expand Down
4 changes: 2 additions & 2 deletions Documentation/rbac.md
Expand Up @@ -34,7 +34,7 @@ for the different `ServiceAccounts` Rook uses to start the Rook Storage Pods.
You need one `PodSecurityPolicy` that allows privileged `Pod` execution. Here is an example:

```yaml
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: PodSecurityPolicy
metadata:
name: privileged
Expand Down Expand Up @@ -83,7 +83,7 @@ metadata:
name: privileged-psp-user
rules:
- apiGroups:
- extensions
- apps
resources:
- podsecuritypolicies
resourceNames:
Expand Down
2 changes: 0 additions & 2 deletions Gopkg.lock

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

1 change: 1 addition & 0 deletions PendingReleaseNotes.md
Expand Up @@ -23,6 +23,7 @@

- Rook no longer supports Kubernetes `1.8` and `1.9`.
- Rook no longer supports running more than one monitor on the same node when `hostNetwork` and `allowMultiplePerNode` are `true`.
- Rook Operator switches from Extensions v1beta1 to use Apps v1 API for DaemonSet and Deployment.

### Ceph

Expand Down
4 changes: 2 additions & 2 deletions cluster/charts/rook-ceph/templates/clusterrole.yaml
Expand Up @@ -25,7 +25,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
resources:
- deployments
- daemonsets
Expand Down Expand Up @@ -155,7 +155,7 @@ metadata:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
rules:
- apiGroups:
- extensions
- apps
resources:
- podsecuritypolicies
resourceNames:
Expand Down
2 changes: 1 addition & 1 deletion cluster/charts/rook-ceph/templates/psp.yaml
Expand Up @@ -11,7 +11,7 @@
#
# More info on PSP ordering : https://kubernetes.io/docs/concepts/policy/pod-security-policy/#policy-order

apiVersion: extensions/v1beta1
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: 00-rook-ceph-operator
Expand Down
2 changes: 1 addition & 1 deletion cluster/charts/rook-ceph/templates/role.yaml
Expand Up @@ -22,7 +22,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
resources:
- daemonsets
verbs:
Expand Down
2 changes: 1 addition & 1 deletion cluster/examples/coreos/after-reboot-daemonset.yaml
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ceph-after-reboot-check
Expand Down
2 changes: 1 addition & 1 deletion cluster/examples/coreos/before-reboot-daemonset.yaml
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: ceph-before-reboot-check
Expand Down
4 changes: 2 additions & 2 deletions cluster/examples/kubernetes/ceph/operator-with-csi.yaml
Expand Up @@ -204,7 +204,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
resources:
- deployments
- daemonsets
Expand Down Expand Up @@ -242,7 +242,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
resources:
- daemonsets
verbs:
Expand Down
4 changes: 2 additions & 2 deletions cluster/examples/kubernetes/ceph/operator.yaml
Expand Up @@ -204,7 +204,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there are changes to the rbac i would have expected the upgrade_test.go to need an update, otherwise the rbac will not be updated in the test. See here for an example of updating the rbac for a similar change. The upgrade test is what helps us put the final upgrade documentation ready when it's time for release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

resources:
- deployments
- daemonsets
Expand Down Expand Up @@ -241,7 +241,7 @@ rules:
- update
- delete
- apiGroups:
- extensions
- apps
resources:
- daemonsets
verbs:
Expand Down
4 changes: 2 additions & 2 deletions cluster/examples/kubernetes/edgefs/cluster.yaml
Expand Up @@ -55,7 +55,7 @@ subjects:
name: rook-edgefs-cluster
namespace: rook-edgefs
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: PodSecurityPolicy
metadata:
name: privileged
Expand Down Expand Up @@ -83,7 +83,7 @@ metadata:
name: privileged-psp-user
rules:
- apiGroups:
- extensions
- apps
resources:
- podsecuritypolicies
resourceNames:
Expand Down
4 changes: 2 additions & 2 deletions cluster/examples/kubernetes/edgefs/operator.yaml
Expand Up @@ -88,7 +88,7 @@ rules:
- apiGroups: ["apps"]
resources: ["statefulsets", "statefulsets/scale"]
verbs: ["create", "delete", "deletecollection", "patch", "update"]
- apiGroups: ["extensions"]
- apiGroups: ["apps"]
resources: ["deployments", "daemonsets", "replicasets", "statefulsets"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
---
Expand All @@ -105,7 +105,7 @@ rules:
- apiGroups: [""]
resources: ["pods", "nodes", "configmaps"]
verbs: ["get", "list", "watch", "patch", "create", "update", "delete"]
- apiGroups: ["extensions"]
- apiGroups: ["apps"]
resources: ["daemonsets"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
---
Expand Down
2 changes: 1 addition & 1 deletion cluster/examples/kubernetes/wordpress.yaml
Expand Up @@ -26,7 +26,7 @@ spec:
requests:
storage: 20Gi
---
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
Expand Down
19 changes: 12 additions & 7 deletions pkg/operator/ceph/agent/agent.go
Expand Up @@ -26,8 +26,8 @@ import (

"github.com/coreos/pkg/capnslog"
"github.com/rook/rook/pkg/operator/k8sutil"
apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
kserrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -103,13 +103,18 @@ func (a *Agent) createAgentDaemonSet(namespace, agentImage, serviceAccount strin
}

privileged := true
ds := &extensions.DaemonSet{
ds := &apps.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: agentDaemonsetName,
},
Spec: extensions.DaemonSetSpec{
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
Type: extensions.RollingUpdateDaemonSetStrategyType,
Spec: apps.DaemonSetSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": agentDaemonsetName,
},
},
UpdateStrategy: apps.DaemonSetUpdateStrategy{
Type: apps.RollingUpdateDaemonSetStrategyType,
},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -235,13 +240,13 @@ func (a *Agent) createAgentDaemonSet(namespace, agentImage, serviceAccount strin
}
}

_, err = a.clientset.Extensions().DaemonSets(namespace).Create(ds)
_, err = a.clientset.Apps().DaemonSets(namespace).Create(ds)
if err != nil {
if !kserrors.IsAlreadyExists(err) {
return fmt.Errorf("failed to create rook-ceph-agent daemon set. %+v", err)
}
logger.Infof("rook-ceph-agent daemonset already exists, updating ...")
_, err = a.clientset.Extensions().DaemonSets(namespace).Update(ds)
_, err = a.clientset.Apps().DaemonSets(namespace).Update(ds)
if err != nil {
return fmt.Errorf("failed to update rook-ceph-agent daemon set. %+v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/operator/ceph/agent/agent_test.go
Expand Up @@ -62,7 +62,7 @@ func TestStartAgentDaemonset(t *testing.T) {
assert.Nil(t, err)

// check daemonset parameters
agentDS, err := clientset.Extensions().DaemonSets(namespace).Get("rook-ceph-agent", metav1.GetOptions{})
agentDS, err := clientset.Apps().DaemonSets(namespace).Get("rook-ceph-agent", metav1.GetOptions{})
assert.Nil(t, err)
assert.Equal(t, namespace, agentDS.Namespace)
assert.Equal(t, "rook-ceph-agent", agentDS.Name)
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestStartAgentDaemonsetWithToleration(t *testing.T) {
assert.Nil(t, err)

// check daemonset toleration
agentDS, err := clientset.Extensions().DaemonSets(namespace).Get("rook-ceph-agent", metav1.GetOptions{})
agentDS, err := clientset.Apps().DaemonSets(namespace).Get("rook-ceph-agent", metav1.GetOptions{})
assert.Nil(t, err)
assert.Equal(t, 1, len(agentDS.Spec.Template.Spec.Tolerations))
assert.Equal(t, "mysa", agentDS.Spec.Template.Spec.ServiceAccountName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/mgr/mgr.go
Expand Up @@ -108,7 +108,7 @@ func (c *Cluster) Start() error {
// start the deployment
d := c.makeDeployment(mgrConfig)
logger.Debugf("starting mgr deployment: %+v", d)
_, err := c.context.Clientset.ExtensionsV1beta1().Deployments(c.Namespace).Create(d)
_, err := c.context.Clientset.Apps().Deployments(c.Namespace).Create(d)
if err != nil {
if !errors.IsAlreadyExists(err) {
return fmt.Errorf("failed to create mgr deployment %s. %+v", resourceName, err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/operator/ceph/cluster/mgr/mgr_test.go
Expand Up @@ -30,14 +30,14 @@ import (
testop "github.com/rook/rook/pkg/operator/test"
exectest "github.com/rook/rook/pkg/util/exec/test"
"github.com/stretchr/testify/assert"
apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestStartMGR(t *testing.T) {
var deploymentsUpdated *[]*extensions.Deployment
var deploymentsUpdated *[]*apps.Deployment
updateDeploymentAndWait, deploymentsUpdated = testopk8s.UpdateDeploymentAndWaitStub()

executor := &exectest.MockExecutor{
Expand Down Expand Up @@ -99,7 +99,7 @@ func validateStart(t *testing.T, c *Cluster) {
}
logger.Infof("Looking for cephmgr replica %d", i)
daemonName := mgrNames[i]
_, err := c.context.Clientset.ExtensionsV1beta1().Deployments(c.Namespace).Get(fmt.Sprintf("rook-ceph-mgr-%s", daemonName), metav1.GetOptions{})
_, err := c.context.Clientset.Apps().Deployments(c.Namespace).Get(fmt.Sprintf("rook-ceph-mgr-%s", daemonName), metav1.GetOptions{})
assert.Nil(t, err)
}

Expand Down
15 changes: 9 additions & 6 deletions pkg/operator/ceph/cluster/mgr/spec.go
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
opspec "github.com/rook/rook/pkg/operator/ceph/spec"
"github.com/rook/rook/pkg/operator/k8sutil"
apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *extensions.Deployment {
func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *apps.Deployment {
podSpec := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: mgrConfig.ResourceName,
Expand Down Expand Up @@ -68,17 +68,20 @@ func (c *Cluster) makeDeployment(mgrConfig *mgrConfig) *extensions.Deployment {
}

replicas := int32(1)
d := &extensions.Deployment{
d := &apps.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: mgrConfig.ResourceName,
Namespace: c.Namespace,
Labels: c.getPodLabels(mgrConfig.DaemonID),
},
Spec: extensions.DeploymentSpec{
Spec: apps.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: c.getPodLabels(mgrConfig.DaemonID),
},
Template: podSpec,
Replicas: &replicas,
Strategy: extensions.DeploymentStrategy{
Type: extensions.RecreateDeploymentStrategyType,
Strategy: apps.DeploymentStrategy{
Type: apps.RecreateDeploymentStrategyType,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/mon/health.go
Expand Up @@ -300,7 +300,7 @@ func (c *Cluster) removeMon(daemonName string) error {
var gracePeriod int64
propagation := metav1.DeletePropagationForeground
options := &metav1.DeleteOptions{GracePeriodSeconds: &gracePeriod, PropagationPolicy: &propagation}
if err := c.context.Clientset.Extensions().Deployments(c.Namespace).Delete(resourceName, options); err != nil {
if err := c.context.Clientset.Apps().Deployments(c.Namespace).Delete(resourceName, options); err != nil {
if errors.IsNotFound(err) {
logger.Infof("dead mon %s was already gone", resourceName)
} else {
Expand Down
17 changes: 8 additions & 9 deletions pkg/operator/ceph/cluster/mon/health_test.go
Expand Up @@ -32,15 +32,14 @@ import (
"github.com/rook/rook/pkg/operator/test"
exectest "github.com/rook/rook/pkg/util/exec/test"
"github.com/stretchr/testify/assert"
apps "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
extensions "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/kubelet/apis"
)

func TestCheckHealth(t *testing.T) {
var deploymentsUpdated *[]*extensions.Deployment
var deploymentsUpdated *[]*apps.Deployment
updateDeploymentAndWait, deploymentsUpdated = testopk8s.UpdateDeploymentAndWaitStub()

executor := &exectest.MockExecutor{
Expand Down Expand Up @@ -93,7 +92,7 @@ func TestCheckHealth(t *testing.T) {
}

func TestCheckHealthNotFound(t *testing.T) {
var deploymentsUpdated *[]*extensions.Deployment
var deploymentsUpdated *[]*apps.Deployment
updateDeploymentAndWait, deploymentsUpdated = testopk8s.UpdateDeploymentAndWaitStub()

executor := &exectest.MockExecutor{
Expand Down Expand Up @@ -205,7 +204,7 @@ func TestCheckHealthTwoMonsOneNode(t *testing.T) {
for i := 0; i < len(monNames); i++ {
monConfig := testGenMonConfig(monNames[i])
d := c.makeDeployment(monConfig, "node0")
_, err := clientset.ExtensionsV1beta1().Deployments(c.Namespace).Create(d)
_, err := clientset.Apps().Deployments(c.Namespace).Create(d)
assert.Nil(t, err)
po := c.makeMonPod(monConfig, "node0")
_, err = clientset.CoreV1().Pods(c.Namespace).Create(po)
Expand Down Expand Up @@ -248,8 +247,8 @@ func TestCheckHealthTwoMonsOneNode(t *testing.T) {
assert.Equal(t, "node2", c.mapping.Node["c"].Name)

// check if mon b has been deleted
var dlist *v1beta1.DeploymentList
dlist, err = clientset.ExtensionsV1beta1().Deployments(c.Namespace).List(metav1.ListOptions{})
var dlist *apps.DeploymentList
dlist, err = clientset.Apps().Deployments(c.Namespace).List(metav1.ListOptions{})
assert.Nil(t, err)
deleted := true
for _, d := range dlist.Items {
Expand All @@ -265,7 +264,7 @@ func TestCheckHealthTwoMonsOneNode(t *testing.T) {
assert.Nil(t, err)

// check that nothing has changed
dlist, err = clientset.ExtensionsV1beta1().Deployments(c.Namespace).List(metav1.ListOptions{})
dlist, err = clientset.Apps().Deployments(c.Namespace).List(metav1.ListOptions{})
assert.Nil(t, err)

for _, d := range dlist.Items {
Expand Down Expand Up @@ -362,7 +361,7 @@ func TestCheckMonsValid(t *testing.T) {
}

func TestAddRemoveMons(t *testing.T) {
var deploymentsUpdated *[]*extensions.Deployment
var deploymentsUpdated *[]*apps.Deployment
updateDeploymentAndWait, deploymentsUpdated = testopk8s.UpdateDeploymentAndWaitStub()

monQuorumResponse := clienttest.MonInQuorumResponse()
Expand Down