投稿時間:2022-09-18 14:14:04 RSSフィード2022-09-18 14:00 分まとめ(13件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita root権限を使わないpythonのdocker環境を作る https://qiita.com/naozo-se/items/17cb127fab3783361ca4 windowspr 2022-09-18 13:30:00
js JavaScriptタグが付けられた新着投稿 - Qiita paizaラーニング レベルアップ問題集 幅優先探索・深さ優先探索メニュー JavaScript 領域の個数 https://qiita.com/ZampieriIsa/items/aef9e32850b716361cbe javascript 2022-09-18 13:21:39
js JavaScriptタグが付けられた新着投稿 - Qiita 【TypeScript】型定義ファイルのないライブラリのインポートエラーについて【React】 https://qiita.com/SyoInoue/items/340ff06f88c43c769cd9 reactan 2022-09-18 13:17:48
Linux Ubuntuタグが付けられた新着投稿 - Qiita Samba の使い方 https://qiita.com/ekzemplaro/items/fa067e0be098cf6775c5 smbclientvversionubuntu 2022-09-18 13:59:36
Docker dockerタグが付けられた新着投稿 - Qiita root権限を使わないpythonのdocker環境を作る https://qiita.com/naozo-se/items/17cb127fab3783361ca4 windowspr 2022-09-18 13:30:00
Ruby Railsタグが付けられた新着投稿 - Qiita 部分テンプレートにとlayoutについて https://qiita.com/tyosu/items/8eed4e8725f1ddabc115 layout 2022-09-18 13:27:08
海外TECH DEV Community Add QR code to React websites in 2 minutes 😎✨ https://dev.to/ruppysuppy/add-qr-code-to-react-websites-in-2-minutes-j05 Add QR code to React websites in minutes Love them or hate them the cool kids around the block use them If you want to develop an app that relies on sharing stuff QR codes are a great tool to get users hooked But it feels too difficult to implementFret not my friend this article will guide you through such an easy solution that you can do it with your eyes closed metaphorically speaking of course Let s get started DependenciesThere are a lot of libraries that can be used to generate the QR codes My personal favorite is qrcode which I would be using in this article Install the package using npm i qrcode Setting up the componentWe would start off with a basic component with a text input field as we need some input data to generate the QR code import useState from react export default function App const text setText useState return lt div gt lt input value text onChange e gt setText e target value gt lt br gt lt div gt Generating the QR codeTo generate the QR code we would need a canvas element to render it out import QRCode from qrcode import useEffect useRef useState from react export default function App const text setText useState const canvasRef useRef useEffect gt QRCode toCanvas canvasRef current QR code doesn t work with an empty string so we are using a blank space as a fallback text error gt error amp amp console error error text return lt div gt lt input value text onChange e gt setText e target value gt lt br gt lt canvas ref canvasRef gt lt div gt The following is the end result Using QR code in vanilla JSFrom the package it would have been evident that it is NOT dependent on React to get the job done You can use it with any other framework or even vanilla JS lt index html gt lt div gt lt input id text input gt lt br gt lt canvas id qr code canvas gt lt canvas gt lt div gt script jsconst QRCode require qrcode const input document getElementById text input const canvas document getElementById qr code canvas input addEventListener change event gt QRCode toCanvas canvas event target value error gt error amp amp console error error Use casesAlthough the QR codes can be used to store any data the most frequent use cases are Sharing links amp contact detailsQR code offers unparalleled ease of sharing links and contact details All you need is to scan the code with any app Google Lens is my personal favorite and you are good to go Virtual Cards amp ticketsQR codes can be used for the purpose of verification too Just slap them onto virtual cards or tickets and you can just scan them to verify the permissions or authenticity Adding a digital touchWant to inform your users of all the features of your product but find it hard to cram into a single advertisement Add a QR code with a link to your product details page and let the users explore it on their own Hope this article made it clear how simple it is to add QR codes to your website That s all folks Research says writing down your goals on pen amp paper makes you to more likely to achieve them Check out these notebooks and journals to make the journey of achieving your dreams easier Thanks for readingNeed a Top Rated Front End Development Freelancer to chop away your development woes Contact me on UpworkWant to see what I am working on Check out my Personal Website and GitHubWant to connect Reach out to me on LinkedInI am a Digital Nomad and occasionally travel Follow me on Instagram to check out what I am up to Follow my blogs for Weekly new Tidbits on DevFAQThese are a few commonly asked questions I get So I hope this FAQ section solves your issues I am a beginner how should I learn Front End Web Dev Look into the following articles Front End Development RoadmapFront End Project IdeasWould you mentor me Sorry I am already under a lot of workload and would not have the time to mentor anyone 2022-09-18 04:22:51
海外TECH DEV Community Manage Redis on AWS from Kubernetes https://dev.to/abhirockzz/manage-redis-on-aws-from-kubernetes-jae Manage Redis on AWS from KubernetesUsing AWS Controller for Kubernetes and CDK for KubernetesIn this blog post you will learn how to use ACK with Amazon EKS for creating a for Redis cluster on AWS with Amazon MemoryDB AWS Controllers for Kubernetes also known as ACK leverage Kubernetes Custom Resource and Custom Resource Definitions and give you the ability to manage and use AWS services directly from Kubernetes without needing to define resources outside of the cluster It supports many AWS services including S DynamoDB MemoryDB etc Normally you would define custom resources in ACK using YAML But in this case we will leverage cdks Cloud Development Kit for Kubernetes an open source framework part of CNCF that allows you to define your Kubernetes applications using regular programming languages instead of yaml Thanks to cdks support for Kubernetes Custom Resource definitions we will import MemoryDB ACK CRDs as APIs and then define a cluster using code I will be using Go for this That s not all In addition to the infrastructure we will take care of the application that will represent the application which will connect with the MemoryDB cluster To do this we will use the cdks plus library to define a Kubernetes Deployment and Service to expose it thereby building an end to end solution In the process you will learn about some of other nuances of ACK such as FieldExport etc I have written a few blog posts around cdks and Go that you may find useful Pre requisitesTo follow along step by step in addition to an AWS account you will need to have AWS CLI cdks CLI kubectl helm and the Go programming language installed There are a variety of ways in which you can create an Amazon EKS cluster I prefer using eksctl CLI because of the convenience it offers First set up the MemoryDB controllerMost of the below steps are adapted from the ACK documentation Install an ACK ControllerInstall it using Helm export SERVICE memorydbexport RELEASE VERSION curl sL SERVICE controller releases latest grep tag name cut d f export ACK SYSTEM NAMESPACE ack system you can change the region as requiredexport AWS REGION us east aws ecr public get login password region us east helm registry login username AWS password stdin public ecr awshelm install create namespace n ACK SYSTEM NAMESPACE ack SERVICE controller oci public ecr aws aws controllers ks SERVICE chart version RELEASE VERSION set aws region AWS REGIONTo confirm run kubectl get crd output multiple CRDs NAME CREATED ATacls memorydb services ks aws T Zadoptedresources services ks aws T Zclusters memorydb services ks aws T Zeniconfigs crd ks amazonaws com T Zfieldexports services ks aws T Zparametergroups memorydb services ks aws T Zsecuritygrouppolicies vpcresources ks aws T Zsnapshots memorydb services ks aws T Zsubnetgroups memorydb services ks aws T Zusers memorydb services ks aws T ZSince the controller has to interact with AWS Services make API calls we need to configure IAM Roles for Service Accounts also known as IRSA Refer to Configure IAM Permissions for detailsIRSA configurationFirst create an OIDC identity provider for your cluster export EKS CLUSTER NAME lt name of your EKS cluster gt export AWS REGION lt cluster region gt eksctl utils associate iam oidc provider cluster EKS CLUSTER NAME region AWS REGION approveThe goal is to create an IAM role and attach appropriate permissions via policies We can then create a Kubernetes Service Account and attach the IAM role to it Thus the controller Pod will be able to make AWS API calls Note that we are using providing all DynamoDB permissions to our control via the arn aws iam aws policy AmazonMemoryDBFullAccess policy Thanks to eksctl this can be done with a single line export SERVICE memorydbexport ACK KS SERVICE ACCOUNT NAME ack SERVICE controller recommend using the same nameexport ACK SYSTEM NAMESPACE ack systemexport EKS CLUSTER NAME lt enter EKS cluster name gt export POLICY ARN arn aws iam aws policy AmazonMemoryDBFullAccess IAM role has a format do not change it you can t use any arbitrary nameexport IAM ROLE NAME ack SERVICE controller roleeksctl create iamserviceaccount name ACK KS SERVICE ACCOUNT NAME namespace ACK SYSTEM NAMESPACE cluster EKS CLUSTER NAME role name IAM ROLE NAME attach policy arn POLICY ARN approve override existing serviceaccountsThe policy AmazonMemoryDBFullAccess is chosen as per To confirm you can check whether the IAM role was created and also introspect the Kubernetes service accountaws iam get role role name IAM ROLE NAME query Role Arn output textkubectl describe serviceaccount ACK KS SERVICE ACCOUNT NAME n ACK SYSTEM NAMESPACE you will see similar outputName ack memorydb controllerNamespace ack systemLabels app kubernetes io instance ack memorydb controller app kubernetes io managed by eksctl app kubernetes io name memorydb chart app kubernetes io version v helm sh chart memorydb chart v ks app memorydb chartAnnotations eks amazonaws com role arn arn aws iam role ack memorydb controller role meta helm sh release name ack memorydb controller meta helm sh release namespace ack systemImage pull secrets lt none gt Mountable secrets ack memorydb controller token cmmxTokens ack memorydb controller token cmmxEvents lt none gt For IRSA to take effect you need to restart the ACK Deployment Note the deployment name for ACK service controller from following commandkubectl get deployments n ACK SYSTEM NAMESPACEkubectl n ACK SYSTEM NAMESPACE rollout restart deployment ack memorydb controller memorydb chartConfirm that the Deployment has restarted currently Running and the IRSA is properly configured kubectl get pods n ACK SYSTEM NAMESPACEkubectl describe pod n ACK SYSTEM NAMESPACE ack memorydb controller memorydb chart bd kxk grep s AWS The output should contain following two lines AWS ROLE ARN arn aws iam lt AWS ACCOUNT ID gt role lt IAM ROLE NAME gt AWS WEB IDENTITY TOKEN FILE var run secrets eks amazonaws com serviceaccount tokenNow that we re done with the configuration its time for cdks in action We will go step by step Build and push the application Docker images to private registry in Amazon ECRDeploy MemoryDB along with the application and required configurationTest the application Build Docker image and push to ECRCreate ECR private repositoryLogin to ECR aws ecr get login password region lt enter region gt docker login username AWS password stdin lt enter aws account id gt dkr ecr lt enter region gt amazonaws comCreate private repository aws ecr create repository repository name memorydb app region lt enter region gt Build image and push to ECR if you re on Mac M export DOCKER DEFAULT PLATFORM linux amddocker build t memorydb app docker tag memorydb app latest lt enter aws account id gt dkr ecr lt enter region gt amazonaws com memorydb app latestdocker push lt enter aws account id gt dkr ecr lt enter region gt amazonaws com memorydb app latest Use cdks and kubectl to deploy MemoryDB and the applicationThis is a ready to use cdks project that you can use The entire logic is in main go file I will dive into the nitty gritty of the code in the next section Clone the project from Github and change to the right directory git clone cd memorydb ack cdks goGenerate and deploy manifestsUse cdks synth to generate the manifest for MemoryDB the application as well as required configuration We can then apply it using kubectl export SUBNET ID LIST lt enter comma separated list of subnet IDs should be same as your EKS cluster gt for example export SUBNET ID LIST subnet caecae subnet dacdcaadf subnet cabbaexport SECURITY GROUP ID lt enter security group ID gt for example export SECURITY GROUP ID sg beeexport DOCKER IMAGE lt enter ECR repo that you created earlier gt example export DOCKER IMAGE dkr ecr us east amazonaws com memorydb app latestYou can also add other environment variables MEMORYDB CLUSTER NAME MEMORYDB USERNAME MEMORYDB PASSWORD These are not mandatory and default to memorydb cluster ack cdks demouser and Password respectivelyTo generate the manifests cdks synth check the dist folder you should see these files memorydb ks yaml config ks yaml deployment ks yamlLet s deploy them one by one starting with the one which creates the MemoryDB cluster In addition to the cluster it will also provision the supporting components including ACL User and Subnet Groups kubectl apply f dist memorydb ks yaml outputsecret memdb secret createdusers memorydb services ks aws demouser createdacls memorydb services ks aws demo acl createdsubnetgroups memorydb services ks aws demo subnet group createdclusters memorydb services ks aws memorydb cluster ack cdksKubernetes Secret is used to hold the password for MemoryDB cluster user This initiates the cluster creation You can check the status using the AWS console Once the creation is complete you can test connectivity with redis cli run this from EC instance in the same subnet as the clusterexport REDIS lt enter cluster endpoint gt example export REDIS clustercfg memorydb cluster ack cdks smtjf memorydb us east amazonaws comredis cli h REDIS c user demouser pass Password tls insecureLet s apply second manifest This will create configuration related components i e ConfigMap and FieldExports these are required by our application to be deployed after this kubectl apply f dist config ks yaml outputconfigmap export memorydb info createdfieldexports services ks aws export memorydb endpoint createdfieldexports services ks aws export memorydb username createdIn this case we create two FieldExports to extract data from the cluster from status clusterEndpoint address and user spec name resources that we created before and seed it into a ConfigMap ConfigMap and FieldExport FieldExport is an ACK component that can export any spec or status field from an ACK resource into a Kubernetes ConfigMap or Secret You can read up on the details in the ACK docs along with some examples You should be able to confirm by checking the FieldExport and ConfigMap kubectl get fieldexport outputNAME AGEexport memorydb endpoint sexport memorydb username skubectl get configmap export memorydb info o yamlWe started out with a blank ConfigMap but ACK magically populated it with the required attributes apiVersion vdata default export memorydb endpoint clustercfg memorydb cluster ack cdks smtjf memorydb us east amazonaws com default export memorydb username demouserimmutable falsekind ConfigMap omittedLet s create the application resources Deployment and the Service kubectl apply f dist deployment ks yaml outputdeployment apps memorydb app createdservice memorydb app service configuredSince the Service type is LoadBalancer an appropriate AWS Load Balancer will be provisioned to allow for external access Check Pod and Service kubectl get podskubectl get service memorydb app service to get the load balancer IPAPP URL kubectl get service memorydb app service o jsonpath status loadBalancer ingress hostname echo APP URL output exampleadbbadabbaccea us east elb amazonaws comYou have deployed the application and know the endpoint over which it s publicly accessible Here is a high level view of the current architecture Now you can access the application It s quite simple it exposes a couple of HTTP endpoints to write and read data from Redis you can check it on GitHub create a couple of users this will be added as a HASH in Rediscurl i X POST d email user foo com name user http APP URL curl i X POST d email user foo com name user http APP URL HTTP OKContent Length search for user via emailcurl i http APP URL user foo comHTTP OKContent Length Content Type text plain charset utf email user foo com name user If you get a Could not resolve host error while accessing the LB URL wait for a minute or so and re tryOnce you re done don t forget to delete resources delete MemoryDB cluster configuration and the applicationkubectl delete f dist to uninstall the ACK controllerexport SERVICE memorydbhelm uninstall n ACK SYSTEM NAMESPACE ack SERVICE controller delete the EKS cluster if created via eksctl eksctl delete cluster name lt enter name of eks cluster gt So far you deployed the ACK controller for MemoryDB setup a cluster an application that connects to it and tested the end to end solution Great Now let s look at the cdks code that makes it all happen The logic is divided into three Charts I will only focus on key sections of the code and rest will be omitted for brevity You can refer to the complete code on GitHub Code walk throughMemoryDB and related componentsWe start by defining the MemoryDB cluster along with the required components ACL User and Subnet Group func NewMemoryDBChart scope constructs Construct id string props MyChartProps cdks Chart secret cdksplus NewSecret chart jsii String password amp cdksplus SecretProps Metadata amp cdks ApiObjectMetadata Name jsii String secretName StringData amp map string string password jsii String memoryDBPassword user users memorydbservicesksaws NewUser chart jsii String user amp users memorydbservicesksaws UserProps Metadata amp cdks ApiObjectMetadata Name jsii String memoryDBUsername Spec amp users memorydbservicesksaws UserSpec Name jsii String memoryDBUsername AccessString jsii String memoryDBUserAccessString AuthenticationMode amp users memorydbservicesksaws UserSpecAuthenticationMode Type jsii String Password Passwords amp users memorydbservicesksaws UserSpecAuthenticationModePasswords Name secret Name Key jsii String secretKeyName ACL references the User defined above acl acl memorydbservicesksaws NewAcl chart jsii String acl amp acl memorydbservicesksaws AclProps Metadata amp cdks ApiObjectMetadata Name jsii String memoryDBACLName Spec amp acl memorydbservicesksaws AclSpec Name jsii String memoryDBACLName UserNames jsii Strings user Name The subnet IDs for subnet group as well as the security group ID for the cluster are read from environment variables subnetGroup subnetgroups memorydbservicesksaws NewSubnetGroup chart jsii String sg amp subnetgroups memorydbservicesksaws SubnetGroupProps Metadata amp cdks ApiObjectMetadata Name jsii String memoryDBSubnetGroup Spec amp subnetgroups memorydbservicesksaws SubnetGroupSpec Name jsii String memoryDBSubnetGroup SubnetIDs jsii Strings strings Split subnetIDs same as EKS cluster Finally the MemoryDB cluster is defined it references all the resources created above it has been omitted on purpose memoryDBCluster memorydbservicesksaws NewCluster chart jsii String memorydb ack cdks amp memorydbservicesksaws ClusterProps Metadata amp cdks ApiObjectMetadata Name jsii String memoryDBClusterName Spec amp memorydbservicesksaws ClusterSpec Name jsii String memoryDBClusterName omitted return chart ConfigurationThen we move on to the next chart that handles the configuration related aspects It defines a ConfigMap which is empty and FieldExports one each for the MemoryDB cluster endpoint and username the password is read from the Secret As soon as these are created the ConfigMap is populated with the required data as per from and to configuration in the FieldExport func NewConfigChart scope constructs Construct id string props MyChartProps cdks Chart cfgMap cdksplus NewConfigMap chart jsii String config map amp cdksplus ConfigMapProps Metadata amp cdks ApiObjectMetadata Name jsii String configMapName fieldExportForClusterEndpoint servicesksaws NewFieldExport chart jsii String fexp cluster amp servicesksaws FieldExportProps Metadata amp cdks ApiObjectMetadata Name jsii String fieldExportNameForClusterEndpoint Spec amp servicesksaws FieldExportSpec From amp servicesksaws FieldExportSpecFrom Path jsii String status clusterEndpoint address Resource amp servicesksaws FieldExportSpecFromResource Group jsii String memorydb services ks aws Kind jsii String Cluster Name memoryDBCluster Name To amp servicesksaws FieldExportSpecTo Name cfgMap Name Kind servicesksaws FieldExportSpecToKind CONFIGMAP fieldExportForUsername servicesksaws NewFieldExport chart jsii String fexp username amp servicesksaws FieldExportProps Metadata amp cdks ApiObjectMetadata Name jsii String fieldExportNameForUsername Spec amp servicesksaws FieldExportSpec From amp servicesksaws FieldExportSpecFrom Path jsii String spec name Resource amp servicesksaws FieldExportSpecFromResource Group jsii String memorydb services ks aws Kind jsii String User Name user Name To amp servicesksaws FieldExportSpecTo Name cfgMap Name Kind servicesksaws FieldExportSpecToKind CONFIGMAP return chart The application chartFinally we deal with the Deployment in its dedicated Chart it makes use of the configuration objects we defined in the earlier chart func NewDeploymentChart scope constructs Construct id string props MyChartProps cdks Chart dep cdksplus NewDeployment chart jsii String memorydb app deployment amp cdksplus DeploymentProps Metadata amp cdks ApiObjectMetadata Name jsii String memorydb app The next important part is the container and it s configuration We specify the ECR image repository along with the environment variables they reference the ConfigMap we defined in the previous chart everything is connected container dep AddContainer amp cdksplus ContainerProps Name jsii String memorydb app container Image jsii String appDockerImage Port jsii Number appPort container Env AddVariable jsii String MEMORYDB CLUSTER ENDPOINT cdksplus EnvValue FromConfigMap cfgMap jsii String default fieldExportForClusterEndpoint Name amp cdksplus EnvValueFromConfigMapOptions Optional jsii Bool false container Env AddVariable jsii String MEMORYDB USERNAME cdksplus EnvValue FromConfigMap cfgMap jsii String default fieldExportForUsername Name amp cdksplus EnvValueFromConfigMapOptions Optional jsii Bool false container Env AddVariable jsii String MEMORYDB PASSWORD cdksplus EnvValue FromSecretValue amp cdksplus SecretValue Secret secret Key jsii String password amp cdksplus EnvValueFromSecretOptions Finally we define the Service type LoadBalancer which enables external application access and tie it all together in the main function dep ExposeViaService amp cdksplus DeploymentExposeViaServiceOptions Name jsii String memorydb app service ServiceType cdksplus ServiceType LOAD BALANCER Ports amp cdksplus ServicePort Protocol cdksplus Protocol TCP Port jsii Number lbPort TargetPort jsii Number appPort func main app cdks NewApp nil memorydb NewMemoryDBChart app memorydb nil config NewConfigChart app config nil config AddDependency memorydb deployment NewDeploymentChart app deployment nil deployment AddDependency memorydb config app Synth That s all for now Wrap up Combining AWS Controllers for Kubernetes and cdks can prove useful if you want to manage AWS services as well as the Kubernetes applications using code not yaml In this blog you saw how to do this in the context of MemoryDB and an application that was composed of a Deployment and Service I encourage you to try out other AWS services as well here is a complete list Until then Happy Building 2022-09-18 04:20:45
海外ニュース Japan Times latest articles Thousands in shelters as southwestern Japan braces for dangerous typhoon https://www.japantimes.co.jp/news/2022/09/18/national/typhoon-nanmadol-evacuation/ Thousands in shelters as southwestern Japan braces for dangerous typhoonThe weather agency has issued a rare special warning for Kagoshima Prefecture ーan alert that is issued only when it forecasts dangerous conditions seen 2022-09-18 13:16:29
ニュース BBC News - Home Joe Biden arrives in London for Queen's funeral https://www.bbc.co.uk/news/uk-62943911?at_medium=RSS&at_campaign=KARANGA london 2022-09-18 04:02:36
北海道 北海道新聞 秋の高校野球支部予選・9月18日の試合結果 https://www.hokkaido-np.co.jp/article/732899/ 試合結果 2022-09-18 13:26:18
北海道 北海道新聞 大谷13勝目、7回無失点 規定投球回まであと14イニング https://www.hokkaido-np.co.jp/article/732932/ 大リーグ 2022-09-18 13:16:00
IT 週刊アスキー 『ライザ3』の広大なフィールドや新要素“鍵”の使い方が明らかに!世界初公開の実機プレイ配信をチェック【TGS2022】 https://weekly.ascii.jp/elem/000/004/106/4106021/ liveintgs 2022-09-18 13:35:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)