-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ole Markus With
committed
Aug 6, 2021
1 parent
70a6064
commit a684180
Showing
9 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package model | ||
|
||
import ( | ||
"k8s.io/kops/upup/pkg/fi" | ||
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks" | ||
) | ||
|
||
type PrefixBuilder struct { | ||
*NodeupModelContext | ||
} | ||
|
||
var _ fi.ModelBuilder = &PrefixBuilder{} | ||
|
||
func (b *PrefixBuilder) Build(c *fi.ModelBuilderContext) error { | ||
c.AddTask(&nodetasks.Prefix{ | ||
Name: "prefix", | ||
}) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package nodetasks | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/service/ec2" | ||
"k8s.io/kops/upup/pkg/fi" | ||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup" | ||
"k8s.io/kops/upup/pkg/fi/nodeup/local" | ||
) | ||
|
||
type Prefix struct { | ||
Name string | ||
} | ||
|
||
var _ fi.HasName = &Prefix{} | ||
|
||
func (f *Prefix) GetName() *string { | ||
return &f.Name | ||
} | ||
|
||
// String returns a string representation, implementing the Stringer interface | ||
func (p *Prefix) String() string { | ||
return fmt.Sprintf("Prefix: %s", p.Name) | ||
} | ||
|
||
func (e *Prefix) Find(c *fi.Context) (*Prefix, error) { | ||
return nil, nil | ||
} | ||
func (e *Prefix) Run(c *fi.Context) error { | ||
return fi.DefaultDeltaRunMethod(e, c) | ||
} | ||
|
||
func (_ *Prefix) CheckChanges(a, e, changes *Prefix) error { | ||
return nil | ||
} | ||
|
||
func (_ *Prefix) RenderLocal(t *local.LocalTarget, a, e, changes *Prefix) error { | ||
|
||
awsCloud := t.Cloud.(awsup.AWSCloud) | ||
|
||
netifs, err := awsCloud.EC2().DescribeNetworkInterfaces(&ec2.DescribeNetworkInterfacesInput{ | ||
Filters: []*ec2.Filter{ | ||
{ | ||
Name: fi.String("attachment.instance-id"), | ||
Values: []*string{ | ||
&t.InstanceID, | ||
}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to get interface: %w", err) | ||
} | ||
|
||
netif := netifs.NetworkInterfaces[0] | ||
|
||
_, err = awsCloud.EC2().AssignIpv6Addresses(&ec2.AssignIpv6AddressesInput{ | ||
Ipv6PrefixCount: fi.Int64(1), | ||
NetworkInterfaceId: netif.NetworkInterfaceId, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to assign ip address: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters